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!
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!
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.
So I Made A Link Here:
https://pastebin.com/qBBJcc4T
Just Copy And Paste It Into A Web 'URL'