Hello.
I am currently making a block where if it is hit, it freezes the charater controls and makes the player move. This does work however it disables controls for every other player in the server. I have been attempting to fix this for hours but I had absolutely 0 luck.
Here is the script I am using:
--###----------[[SERVICES]]----------###-- local ContextActionService = game:GetService("ContextActionService") local Players = game:GetService("Players") --###----------[[VARIABLES]]----------###-- local AutoWalk = workspace.Map.Rooms.Downstairs["Room 1"].AutoWalk_Stairs local FreezeCharacter = "DisengageControls" local Debounce = false local DestinationPoint = Vector3.new(-20.209, 3.29, -480.929) --###----------[[FUNCTIONS]]----------###-- local function AutoWalkOnTouch(CharacterBodyPart) local Humanoid = CharacterBodyPart.Parent:FindFirstChildWhichIsA("Humanoid") if (Humanoid) then if not (Debounce) then Debounce = true --------------- Humanoid.JumpPower = 0 --------------- ContextActionService:BindAction( FreezeCharacter, --------------- function() return Enum.ContextActionResult.Sink end, --------------- false, unpack(Enum.PlayerActions:GetEnumItems()) ) --------------- Humanoid:MoveTo(DestinationPoint) --------------- ContextActionService:UnbindAction(FreezeCharacter) Debounce = false end end end --###----------[[SETUP]]----------###-- AutoWalk.Touched:Connect(AutoWalkOnTouch)
If anybody could help me with this, it would be great.
Thanks
Complete edit:
The problem here is that .Touched fires to everyone when every part touches it. So instead, use Players:GetPlayerFromCharater() and make sure the player is the local player. On every touch the function runs to every player.