script.Parent.PrimaryPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
if game.Players:FindFirstChild(hit.Parent.Name) then
local Player = game.Players:FindFirstChild(hit.Parent.Name)
local level = Player:WaitForChild('leaderstats'):WaitForChild('Level')
if level.Value == script.Parent.Name - 1 then
level.Value = script.Parent.Name
script.Parent.Button.BrickColor = BrickColor.new("Bright green")
script.Parent.Button.Star.Enabled = true
wait(0.5)
script.Parent.Button.BrickColor = BrickColor.new("Bright yellow")
script.Parent.Button.Star.Enabled = false
end
end
end
end)
Trying to change to working with Stage 1+ change.
When someone touch it do color effect.
This script using “level.Value”
Can someone help?
I tryed edit to work with my system used “player.leaderstats.Stage.Value”, but still not work.
Thanks.
Can you change your current code to the following and tell me what you see in output:
script.Parent.PrimaryPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player then
print("running")
local level = Player:WaitForChild('leaderstats'):WaitForChild('Level')
print("Found stat")
print(level.ClassName)
if level.Value == tonumber(script.Parent.Name) - 1 then
print("I'm assuming the if statement above was the previous issue??")
level.Value = script.Parent.Name
script.Parent.Button.BrickColor = BrickColor.new("Bright green")
script.Parent.Button.Star.Enabled = true
wait(0.5)
script.Parent.Button.BrickColor = BrickColor.new("Bright yellow")
script.Parent.Button.Star.Enabled = false
end
end
end
end)
Remove the “PrimaryPart” from the touch connection. So instead do this since I don’t think the scripts parent is a model with a primaryPart:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player then
print("running")
local level = Player:WaitForChild('leaderstats'):WaitForChild('Level')
print("Found stat")
print(level.ClassName)
if level.Value == tonumber(script.Parent.Name) - 1 then
print("I'm assuming the if statement above was the previous issue??")
level.Value = script.Parent.Name
script.Parent.Button.BrickColor = BrickColor.new("Bright green")
script.Parent.Button.Star.Enabled = true
wait(0.5)
script.Parent.Button.BrickColor = BrickColor.new("Bright yellow")
script.Parent.Button.Star.Enabled = false
end
end
end
end)
I don’t think this is the right script as neither are creating any values called “Stage” or “Level”. Do you have any type of leaderboard script or anything thats creating the leaderstats folder, as well as these values?