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

Script doesn't change player's speed?

Asked by 3 years ago

I'm trying to make other players stop and the player who pressed "F" still be able to walk

But it makes everyone able to walk

Can anyone help me?

        local plrs = game.Players:GetPlayers()
local p = game.Players.LocalPlayer 
local char = p.Character 
if not p.Character then 
    repeat wait() until p.Character 
end

local human = char.Humanoid 


local UIS = game:GetService("UserInputService")




UIS.InputBegan:Connect(function(inputObject) 

        if inputObject.KeyCode==Enum.KeyCode.F then




        game:GetService("ReplicatedStorage").Purple:FireServer()    


        for i, v in pairs(plrs) do

            v.Character.Humanoid.WalkSpeed = 0

            if v.Name == p.Name then
                v.Character.Humanoid.WalkSpeed = 16
            end

        end






    end
end)

UIS.InputEnded:Connect(function(inputObject)
        if inputObject.KeyCode==Enum.KeyCode.F then

        wait(4)
        game:GetService("ReplicatedStorage").Normal:FireServer()    

        for i, v in pairs(plrs) do

            v.Character.Humanoid.WalkSpeed = 16

        end



    end
end)



The ambient part works though

2 answers

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

You're trying to edit other players' walk speeds through a localscript.

This is how I would do it:

-Player presses F.

-Local script fires a remote event from that player to a server script.

-Server script then Anchors the humanoid root parts of every player except that of the one that pressed F.

Edit: In response to your comment:

Local script:

local player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function()
    game.ReplicatedStorage.RemoteEvent:FireServer()
end)

Server script:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
    for_,  x in pairs(game.Players:GetChildren()) do
        if x.Name ~= player.Name then
            local char = game.Workspace:WaitForChild(x.Name)
            char.HumanoidRootPart.Anchored = true
        end
    end
end)
0
How do I make it anchor everyone's humanoid root parts expect the player? TheNINJA152 85 — 3y
0
How do I make it anchor everyone's humanoid root parts except the player? TheNINJA152 85 — 3y
0
@TheNINJA152 I edited my post to answer your question. Tell me if there are any problems. akatak_prime 48 — 3y
Ad
Log in to vote
-1
Answered by 3 years ago

its simple you don't have to use code heres what you do. start the game and then go to file explorer players <Your roblox username> look inside find child "Humanoid" copy it stop the game paste it into starter player and click humanoid and set speed to whatever you want if you don't understand this then watch this video: https://www.youtube.com/watch?v=Gfhguugae6c

Answer this question