Help. script :
game:GetService('ReplicatedStorage').Print.OnServerEvent:Connect(function(plr)
hum = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
hum.WalkSpeed = 100
end)
Help. script :
game:GetService('ReplicatedStorage').Print.OnServerEvent:Connect(function(plr)
hum = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
hum.WalkSpeed = 100
end)
You’re trying to reference a Local Instance from a Server, that of which is a global space; the Server doesn’t have a "LocalPlayer". This Object path can only be Index through a LocalScript as these programs operate on the Local Machine, which means they’re aware of which Client they are.
This isn’t much of a roadblock though, fortunately, the .OnServerEvent signal contains the Player Object that invoked the Event, we can simply just use that:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("Print")
RemoteEvent.OnServerEvent:Connect(function(Player)
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
if (Humanoid) then
Humanoid.WalkSpeed = 100
end
end)
If this works, don’t forget to accept this answer!
Try this code:
game:GetService('ReplicatedStorage').Print.OnServerEvent:Connect(function(plr)
hum = plr.Character:WaitForChild("Humanoid")
hum.WalkSpeed = 100
end)
wow u insane! thanks bro
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Put your script inside a code block to make it easier for us to read.