If you did manage to get this to work but put the EXP variable outside then it would get only the number the EXP was when this was created. Let’s say the player starts off with 100. Every time they would touch it would just show 100 because you aren’t getting their new EXP value.
player isn’t defined anywhere so it should’ve already errored in output.
It’s also useless because you never actually used it in the script.
Here you’re just getting the service with all the players inside and not the player you want to change.
Here’s a working script.
local PT = script.Parent--The part
local playerService = game:GetService("Players")-- Player service with all the players
PT.Touched:Connect(function(hit)--Touch function
if hit.Parent:FindFirstChild("Humanoid") then--Check if a character touches it using the hit
if playerService:GetPlayerFromCharacter(hit.Parent) then -- Check if it's a player
local Player = playerService:GetPlayerFromCharacter(hit.Parent) -- Get the player
local EXP = Player.Stats.EXP--The stats value object
if EXP.Value >= 100 then
PT.BrickColor = BrickColor.new("Brick yellow")
end
end
end
end)
Please use this to learn and don’t just copy the script and move on with your day because you wouldn’t have learned absolutely nothing.