#Need help disabling player movement when proximity prompt clicked.

1 messages · Page 1 of 1 (latest)

naive steeple
full mauve
#

very common beginner problem. you're desyncing the worldstate on the client from the server. in simple terms, you call disableWalking on the server, and then call restoreWalking on the client. Your code doesn't show anything that will tell the server about this, so the server thinks the client still has its walking disabled. the solution is very obvious, simple, and mundane that even a beginner can fix it: simply communicate to the server what the client has done using remote events. another solution is to do it entirely on one side (pick either server or client and do everything there), noting that gui button presses dont automagically get sent to the server so you'd still need a remote event there.

#

lol that's plain wrong. take this opportunity to learn about truthiness. https://www.lua.org/pil/2.2.html. false and nil evaluate to false, everything else evaluates to true.

#

Conditionals (such as the ones in control structures) consider false and nil as false and anything else as true.

#

Lua considers both zero and the empty string as true in conditional tests

final cloud
#

oh

#

alr

#

thx

full mauve
# full mauve very common beginner problem. you're desyncing the worldstate on the client from...

anyway the most common way this comes up is when you make a frame.visible=true on the server, then set frame.visible=false on the client (close button), and then when the server tries to make it visible again (not knowing the client made it invisible), the server thinks it's still visible from before and nothing happens, making the frame only appear once. exact same identical problem, solved in exactly the same way salute

naive steeple
#

thanks @full mauve

#

someone giving real constructive help

#

yknow who u are stare

full mauve
naive steeple
#

was having an hr long argument

#

in the post

full mauve
full mauve
#

i'm surprised none of them checked and picked up on it

full mauve
naive steeple
#

@full mauve

local ProximityPrompt = workspace:WaitForChild("Starmaptable"):WaitForChild("ProximityPrompt")
local Players = game:GetService("Players")
local player = Players.LocalPlayer

local exitButton = player:WaitForChild("TableGui"):WaitForChild("TableGui"):WaitForChild("ExitButton")

local function disableWalking()
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoid = character:WaitForChild("Humanoid")
    humanoid:ChangeState(Enum.HumanoidStateType.Physics)
end

local function enableWalking()
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoid = character:WaitForChild("Humanoid")
    humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
    wait()
    humanoid:ChangeState(Enum.HumanoidStateType.Running)
end

ProximityPrompt.Triggered:Connect(function(triggeringPlayer)
    if triggeringPlayer == player then
        disableWalking()
    end
end)

exitButton.MouseButton1Click:Connect(function()
    enableWalking()
end)
#

tried this

#

didnt work

naive steeple
#

lets go!

#

i fixed it