This script works in studio but not roblox itself, I don't know what's wrong?
local button = script.Parent game.Players.PlayerAdded:Connect(function() local purchases = game.Players.LocalPlayer:WaitForChild("leaderstats1"):WaitForChild("Purchases2") if purchases.Value == 3 then print("MVP") button.Visible = true button.Parent:WaitForChild("MVP1"):WaitForChild("TextLabel").Visible = false else print("Bye") button.Visible = false end end)
try using game:GetService(Players') for every time you reference the Players in the game. Here's your copy of the script but edited:
local button = script.Parent game:GetService('Players').PlayerAdded:Connect(function() local purchases = game:GetService('Players').LocalPlayer:WaitForChild("leaderstats1"):WaitForChild("Purchases2") if purchases.Value == 3 then print("MVP") button.Visible = true button.Parent:WaitForChild("MVP1"):WaitForChild("TextLabel").Visible = false else print("Bye") button.Visible = false end end)
This script shouldn’t have the “player added function”. Right now every time a player is added, it checks the local player’s stats, not that of the player who is being added. Instead, your script should say:
local Players = game:GetService(“Players”) local player = Players.LocalPlayer local button = script.Parent local purchases = player:WaitForChild("leaderstats1"):WaitForChild("Purchases2") if purchases.Value == 3 then print("MVP") button.Visible = true button.Parent:WaitForChild("MVP1"):WaitForChild("TextLabel").Visible = false else print("Bye") button.Visible = false end end)
Without having the player added function, the script will run when the player joins the game (or when the local script gets replicated which is usually pretty soon after), instead of it waiting until another player joins the game for it to run. Hope this helped!