✓ Accepted answer
I noticed 2 problems with your code, so I'm gonna do my best to explain them.
Problem 1
You can't use LocalPlayer in a server script. This is because LocalPlayer is the client, and the client can't be accessed using a server script. To fix this, use the perimeter you added to the PlayerAdded function.
Problem 2
I would suggest using an elseif statement rather than 2 different PlayerAdded functions. This is because it's completely useless to make 2 PlayerAdded functions because they will both fire every time a new player joins. I also suggest using WaitForChild because if the player hasn't loaded your code will error, returning what didn't load as a nil value.
Your code should look something like this:
local service = game:GetService("GamePassService")
game:GetService("Players").PlayerAdded:Connect(function(player)
if service:PlayerHasPass(player, 1008824264) then
player.leaderstats:WaitForChild("Points").Value = player.leaderstats:WaitForChild("Points").Value + 250
elseif service:PlayerHasPass(player, 1008824264) then
player.Character:WaitForChild("Humanoid").WalkSpeed = 50
end
end)
If this helped, make sure to accept my answer!
1 comment
How would you assume that the server knows what LocalPlayer is?