Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I stop a player from moving - and when they press a button they can start moving?

Asked by
Oyukae 5
3 years ago

Hi! So I am making a 1v1 game, and I added a button to deploy. I also added inventories and customize game settings. Well, my goal was to understand how to temporarily freeze or stop the character from moving, so that they could only press the "Deploy" button and then it goes back to normal. I hope you understand what I mean.

P.S: I have no clue what you mean by fancy works because I only started scripting a month ago. Well, could you also kindly tell me where exactly to place local scripts? Thank you so much!

3 answers

Log in to vote
0
Answered by 3 years ago

One thing you can do is Anchor the HumanoidRootPart.

Make a RemoteEvent in ReplicatedStorage, name it deployEvent or whatever you want and do the following:

Put this inside of a local script inside the button:

script.Parent.MouseButton1Click:Connect(function() -- Check if the button has been pressed
    game.ReplicatedStorage:WaitForChild("deployEvent"):FireServer(player) -- Fire the RemoteEvent
end)

Put this inside of a server script inside ServerScriptService:

game.ReplicatedStorage:WaitForChild("deployEvent").OnServerEvent:Connect(function(player)
    local character = player.Character or player.CharacterAdded:Wait()
    local hRP = character:FindFirstChild("HumanoidRootPart").Anchored = false

    hRP.CFrame = CFrame.new(0,0,0) -- Replace 0,0,0 with the CFrame you want the player to spawn at. You can probably do this by creating another part and using that CFrame to spawn the player.
end)

Note: make sure to anchor the HumanoidRootPart with a script inside of StarterPlayerScripts or StarterCharacterScripts

I hope this helped!

0
Hmm it didn't work - I am so so sorry if this is obvious. Could you kindly add me on roblox and then show it to me on roblox studio? Thank you so much for all your help. My roblox username is Oyukae Oyukae 5 — 3y
0
I just noticed I did a bunch of thing wrong... I'll add you to show what it was supposed to be ColdFoxy07 76 — 3y
0
Or if you have Discord, add me: ColdFoxy#9903. I'll just send you the file. ColdFoxy07 76 — 3y
0
Im Karthikeya0923#0094 Oyukae 5 — 3y
0
Im Karthikeya0923#0094 Oyukae 5 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Just like @ ColdFoxy07 said, you can anchor the HumanoidRootPart so the player won't run anymore. You can use UserInputService to detect when the player starts running again.

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

So I Made A Link Here:

https://pastebin.com/qBBJcc4T

Just Copy And Paste It Into A Web 'URL'

0
The Link: https://pastebin.com/qBBJcc4T 25MouseSensitivity 63 — 3y

Answer this question