You should NOT do game.Workspace[player.Name], here’s the thing, display names are coming to roblox AND the player character has the name as the player display name, not their username. If you wanna reference a player’s character, you should do player.Character
And Never find a player character by searching it’s name on the workspace. Please!
Do
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:connect(function(chr)
– Tanana na
End)
End)
And then you can reference the player’s character via the variable CHR
From what I’ve seen on the code you gave, I think you are using a localscript to apply special stats for a player that buys your gamepass.
You shouldn’t do this because, first, running this on localscript will only run on the client not on the server (To explain: Client gets the 200 HP but the server, and other players can see it only 100 HP), Second, Yes the 200HP works on you but when your character starts to get damage it will go back to 100 or less because the damage is came from the server.
Heres what you gonna do:
Create a normal Script in the ServerScriptService
And paste this script:
local MPS = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamepassID = 00000000
Players.PlayerAdded:Connect(function(thePlayer)
thePlayer.CharacterAdded:Connect(function(playerCharacter)
if MPS:UserOwnsGamePassAsync(thePlayer.UserId, gamepassID) then
if playerCharacter:FindFirstChild("Humanoid") then
playerCharacter.Humanoid.MaxHealth = 200
playerCharacter.Humanoid.Health = 200
end
end
end)
end)