This is the full error:
18:02:15.508 - Workspace.Health:3: attempt to index global 'data' (a nil value) 18:02:15.509 - Stack Begin 18:02:15.509 - Script 'Workspace.Health', Line 3 18:02:15.510 - Stack End
This is the full code:
local me = script.Parent.Parent data = me:findFirstChild("Data") skill = data.Skill.Value function makeLowGrav(Humanoid) print("High health", Humanoid) Humanoid.MaxHealth = 500 + (skill.Value*10) --You can change this if you wish. Humanoid.Health = 500 + (skill.Value*10) --You can change this if you wish. Make sure it is lower than MaxHealth. end function onPlayerRespawn(property, player) -- need to connect to new humanoid if property == "Character" and player.Character ~= nil then makeLowGrav(player.Character.Humanoid) end end function onPlayerEntered(newPlayer) -- VERY UGLY HACK -- Will this leak threads? -- Is the problem even what I think it is (player arrived before character)? while true do if newPlayer.Character ~= nil then break end wait(1) end -- start to listen for new humanoid newPlayer.Changed:connect(function(property) onPlayerRespawn(property, newPlayer) end ) makeLowGrav(newPlayer.Character.Humanoid) end game.Players.ChildAdded:connect(onPlayerEntered)
`
What i'm trying to do with this script is to change the MaxHealth of the roblox user on entery (which works on its own) but the problems lies is the fact that i'm trying to increase the health and maxhealth of the user by a value (in Data) known as Skill. Thus this error comes up frequently. Any ideas?