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

Changing character properties not working?

local listtochange = {
	"WalkSpeed",
	"JumpPower"
}

local change = game.ReplicatedStorage:WaitForChild("ChangeProperty")
change.OnServerEvent:connect(function(property,player)
	game.Players[player].Character.Humanoid[property]=0
end)

game.Players.PlayerAdded:connect(function(player)
	wait(1)
	player.CharacterAdded:connect(function()
	for i,v in pairs(listtochange) do
		change:FireServer(v,player.Name)
	end
	end)
end)

^ That's my script, I get this output:

19:20:05.401 - WalkSpeed is not a valid member of Players 19:20:05.402 - Stack Begin 19:20:05.403 - Script 'ServerScriptService.Change', Line 3 19:20:05.403 - Stack End 19:20:05.403 - JumpPower is not a valid member of Players 19:20:05.403 - Stack Begin 19:20:05.404 - Script 'ServerScriptService.Change', Line 3 19:20:05.404 - Stack End

Can somebody help me with this? Thanks.

1 answer

✓ Accepted answer

RemoteEvents only allow server-communication, they do not allow you to execute code in the same script, neither in a script that's derived from the same class where the event was created.

Here's what you could use:

function dostuff(property, player)
       game.Players[player].Character.Humanoid[property] = 0
end

game.Players.ChildAdded:Connect(function(player)
        wait(1)
        dostuff('WalkSpeed', player.Name)
        dostuff('JumpPower',player.Name)
end)

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