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

Whats wrong with my group walkspeed script?

I tried making it so if they are in my group they get a 5% more walkspeed. It wont work for some reason here it is.

local groupId = 2578189
local speed = 17


local function newPlayer( player )
	if player:IsInGroup(groupId) then -- if player isingroup
		player.CharacterAdded:connect(function( character ) -- wait for character
			local humanoid = character.Humanoid -- character's humanoid
			
			if humanoid then -- if humanoid exisits
			humanoid.WalkSpeed = speed -- set speed
			end;
		end);
	end;
end

game.Players.PlayerAdded:connect( newPlayer ) -- connect event to callback func
table.foreach(game.Players:GetPlayer(), function(i, v)
  newPlayer( v )
end)

Please tell me where I went wrong or what the script is supposed to be. Thanks in advance

1 answer

✓ Accepted answer

I just don't know what went wrong, I'll rewrite the code and see if it works. If it works then I don't know what happened.

local groupId = 2578189
local speed = 16.8 --WalkSpeeds can have decimals.

game:GetService("Players").PlayerAdded:connect(function(plyr)
	plyr.CharacterAdded:connect(function(char)
		if plyr:IsInGroup(groupId) then
			local h = char:WaitForChild("Humanoid")
			h.WalkSpeed = speed
		end
	end)
end)

Hope it helps!

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