public class Player : KinematicBody2D { public int Speed = 200; public override void Ready { // เริ่มต้นค่า } public override void Process(float delta) { var input = new Vector2; input.x = Input.GetActionStrength("uiright") - Input.GetActionStrength("uileft"); input.y = Input.GetActionStrength("uidown") - Input.GetActionStrength("uiup"); if (input.Length > 0) { MoveAndSlide(input.Normalized Speed); } } }
local part = workspace:WaitForChild('MyPart') part.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then print(player.Name .. ' touched the part') end end)