Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I set all players in a games jpower to 0?

I'm making a GUI where if you press a button it will set everyone in the games jump power to 0 but when I make this script it didn't work and I can find anywhere that shows how to do this. I've tried this in a local script and a script but neither of them work.

Heres the script.

script.Parent.MouseButton1Click:Connect(function()
	for i,v in pairs(game.Players) do
		i.Charcater.Humanoid.JumpPower = 0
	end
end)

If fairly new to scripting so this may come as a simple fix but it would be really appreciated.

1 answer

✓ Accepted answer

You will need to make a remote function to change the jump powers for you. If you change the jump powers using a local script, then the other players will not see the changes.

Server Script

local remoteFunction = Instance.new("RemoteFunction", game:GetService("ReplicatedStorage"))

function remoteFunction.OnServerInvoke(player)
    for _, player in pairs(game.Players:GetPlayers()) do
        if player.Character then
            local humanoid = player.Character:FindFirstChildOfClass("Humanoid")

            if humanoid then
                humanoid.JumpPower = 0
            end
        end
    end
end

Local Script

script.Parent.MouseButton1Click:Connect(function()
    game.ReplicatedStorage.RemoteFunction:InvokeServer()
end)

2 comments

0

Alright. I'll check this.

0

It worked! Thank you.

This discussion is preserved as it was. New answers, comments, and votes are closed.