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

Script doesn't change player's speed?

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

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)

3 comments

0

How do I make it anchor everyone's humanoid root parts expect the player?

0

How do I make it anchor everyone's humanoid root parts except the player?

0

@TheNINJA152 I edited my post to answer your question. Tell me if there are any problems.

its simple you don't have to use code heres what you do. start the game and then go to file explorer players 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

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