Need help fixing this, the gist of it is that if the player has >= 5 XP this button label can be pressed and the script will carry out.
disabled = false
local plr = game.Players.LocalPlayer
local button = script.Parent
script.Parent.MouseButton1Click:connect(function()
if plr then
if plr.leaderstats.XP.Value >= 5 then
if disabled == false then
disabled = true
script.Parent.BackgroundColor3 = Color3.new(0.333333, 0.0470588, 0.0470588)
game.Workspace.freiwilligeruhh.RemoteFunction:InvokeServer()
wait(3)
script.Parent.BackgroundColor3 = Color3.new(0.333333, 0.0470588, 0.0470588)
disabled = false
end
end)
local disabled = false
local plr = game.Players.LocalPlayer
local button = script.Parent
script.Parent.MouseButton1Click:connect(function()
if plr then
if plr.leaderstats.XP.Value >= 5 then
if disabled == false then
disabled = true
script.Parent.BackgroundColor3 = Color3.new(0.333333, 0.0470588, 0.0470588)
game.Workspace.freiwilligeruhh.RemoteFunction:InvokeServer()
task.wait(3)
script.Parent.BackgroundColor3 = Color3.new(0.333333, 0.0470588, 0.0470588)
disabled = false
end
end
end
end)
Alright, this might be because the stats is nil and didnt load:
local disabled = false
local plr = game.Players.LocalPlayer
local button = script.Parent
local XP = plr:WaitForChild("leaderstats"):WaitForChild("XP")
button.MouseButton1Click:Connect(function()
if plr and XP.Value >= 5 and not disabled then
disabled = true
button.BackgroundColor3 = Color3.fromRGB(85, 12, 12)
game.Workspace.freiwilligeruhh.RemoteFunction:InvokeServer()
task.wait(3)
button.BackgroundColor3 = Color3.fromRGB(85, 12, 12)
disabled = false
end
end)
local disabled = false
local plr = game.Players.LocalPlayer
local button = script.Parent
local XP = plr:WaitForChild("leaderstats"):WaitForChild("XP")
button.MouseButton1Click:Connect(function()
if plr and tonumber(XP.Value) >= 5 and not disabled then
disabled = true
button.BackgroundColor3 = Color3.fromRGB(85, 12, 12)
game.Workspace.freiwilligeruhh.RemoteFunction:InvokeServer()
task.wait(3)
button.BackgroundColor3 = Color3.fromRGB(85, 12, 12)
disabled = false
end
end)
noticed that the error is the xp value is added as a string so i converted it to number using tonumber()