****Whenever the player finishes the obby they will step on a part which will award XP. But I made an error and I need help. I made EXP a number value so its not part of the leaderstats folder. So it would be player.EXP.Value instead of player.leaderstats.EXP.Value
local Player = game.Players.LocalPlayer local Award = script.Parent local exp = Player.EXP Award.Touched:connect(function(player) if player and player.Parent and player.Parent:FindFirstChild('Humanoid') then exp.Value = exp.Value + 15 end end)
By writing for player.Parent you are referring to Players folder, and that's a mistake. You should also refer to the Player, and not the character.
Here is something I would prefer you use.
script.Parent.Touched:connect(function(hit) -- This makes the function happen when the brick is touched if game.Players:GetPlayerFromCharacter(hit.Parent) then -- The function GetPlayerFromCharacter refers to the Player, we use an if statement to makes sure it's a real player, local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- A variable referring to the Player if player:FindFirstChild("leaderstats") then -- Check if leaderstats exist player.leaderstats.exp.Value = player.leaderstats.exp.Value + 15 -- increases the value end script.Parent:Destroy() -- This is to remove the part that is touched, in case you don't want the player to touched again end end)
The Character is the part of the player that is under the Player folder The Player is the part of the player that is under Workspace