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

How to make my character stop when using this?

Asked by
hh9man 5
6 years ago

So i have a script here that fires my fireball. But i want to make it so it stops the players movement when they press r to fire it. So how could i go about doing that?

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local RemoteEvent = game.Workspace.Fired
local UIS = game:GetService("UserInputService")

local Debounce = false

UIS.InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.R then wait(0.5)
        if Debounce == true then return end
        RemoteEvent:FireServer(Debounce)
    end
end)

2 answers

Log in to vote
0
Answered by
chomboghai 2044 Moderation Voter Community Moderator
6 years ago

You could anchor the character's torso before you perform your wait(0.5), then unanchor it afterwards.

UIS.InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.R then
        if Debounce == true then return end
    -- anchor torso here
    wait(0.5)
    -- unanchor torso here
        RemoteEvent:FireServer(Debounce)
    end
end)
0
How exactly do i anchor the torso there and unanchor it afterwards? hh9man 5 — 6y
0
local torso = Player.Character:FindFirstChild("Torso"), then torso.Anchored = true/false chomboghai 2044 — 6y
0
Wouldn't that enable the character to hover in mid-air while casting the fireball? fredfishy 833 — 6y
0
As long as the fireball can be cast mid-air, then yes. This is just one method to do it, as he said he wanted to "stop player movement", which this does. Another alternative would be InfernoExeuctioner's method of setting jump power and speed to 0. chomboghai 2044 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

To make the player stop moving, you would need to configure with their character.

A method would be to temporarily make the Humanoid's Walkspeed to 0 and back to normal speed.

If you don't want the player to jump, you can also set the Humanoid's JumpPower to 0 and back to its original.

This can be done in the Server Script you linked to the RemoteEvent if this is Filtering Enabled.

Answer this question