#Disable wasd
15 messages · Page 1 of 1 (latest)
But then the MovePlayer wont work
** You are now Level 2! **
Developer Forum | Roblox
I know you can do this by using this code below, but it also unbinds spacebar. I just want the WASD to be unbinded, not the spacebar. --[SERVICES]-- local Players = game:GetService("Players") --[VARIABLES]-- local Player = Players.LocalPlayer local Controls = require(Player.PlayerScripts.PlayerModule):GetControls() --[CODE]-- Controls:Disable()
local function movePlayerToTarget(character, targetPosition)
local humanoid = character:FindFirstChild("Humanoid")
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoid and humanoidRootPart then
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
humanoidRootPart.Anchored = true
humanoid:MoveTo(targetPosition)
humanoid.MoveToFinished:Wait()
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
humanoidRootPart.Anchored = false
end
end
script.Parent.Gate.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if teleporting == false then
local char = hit.Parent
local player = game.Players:FindFirstChild(char.Name)
local alreadyExists = false
for i=1,#list do
if list[i] == char.Name then
alreadyExists = true
end
end
if alreadyExists == false then
if #list < 2 then
table.insert(list, char.Name)
movePlayerToTarget(char, spawnTeleport.Position)
updateGui()
leaveGuiEvent:FireClient(player)
end
player.CharacterRemoving:Connect(function(character)
removeFromList(character)
end)
end
end
end
end)
I wont get moved
like im stuck
Ohh
uhm
I'll try figure it out
like after?
or before?
This might work
local function movePlayerToTarget(character, targetPosition)
local humanoid = character:FindFirstChild("Humanoid")
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoid and humanoidRootPart then
-- Disable movement
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
humanoidRootPart.Anchored = true
-- Move the player
humanoid:MoveTo(targetPosition)
-- Wait until the player reaches the target
humanoid.MoveToFinished:Wait()
-- Restore movement
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
humanoidRootPart.Anchored = false
end
end
script.Parent.Gate.Touched:Connect(function(hit)
local char = hit.Parent
if char:FindFirstChild("Humanoid") and not teleporting then
local player = game.Players:FindFirstChild(char.Name)
if player and not table.find(list, char.Name) then
if #list < 2 then
table.insert(list, char.Name)
movePlayerToTarget(char, spawnTeleport.Position)
updateGui()
leaveGuiEvent:FireClient(player)
end
player.CharacterRemoving:Connect(function(character)
removeFromList(character)
end)
end
end
end)