--Veriables
local Pets = game.ReplicatedStorage.Pets
local Horse = game.ReplicatedStorage.Pets:WaitForChild("Anim")
script.Parent.MouseClick:Connect(function()
local leaderstats = player.leaderstats
local CoinStat = leaderstats and leaderstats:FindFirstChild("Coins")
if CoinStat then
if CoinStat.Value == CoinStat.Value + 100 then
game.StarterGui.MainGui.EggIcon.Visible = false
game.StarterGui.MainGui.EggIcon.Rotation = 9-9
game.StarterGui.MainGui.ImageButton.Visible = true
game.StarterGui.MainGui.PetImages.Cat.Visible = false
end
end
end)
Can I see the whole script? What errors are you getting?
i havent got through the whole script but i was geting a error a the veriable leaderstats. ill send you what the whole output said if need.
Yes, please do so.
It would help out a lot.
--Veriables
local Pets = game.ReplicatedStorage.Pets
local Horse = game.ReplicatedStorage.Pets:WaitForChild("Anim")
script.Parent.MouseClick:Connect(function(plr)
local leaderstats = plr.leaderstats
local CoinStat = leaderstats:FindFirstChild("Coins")
if CoinStat then
if CoinStat.Value == CoinStat.Value + 100 then
plr.PlayerGui.MainGui.EggIcon.Visible = false
plr.PlayerGui.MainGui.EggIcon.Rotation = 9-9
plr.PlayerGui.MainGui.ImageButton.Visible = true
plr.PlayerGui.MainGui.PetImages.Cat.Visible = false
end
end
end)
11:22:44.224 Workspace.Model.Part.ClickDetector.Script:6: attempt to index nil with ‘leaderstats’ - Server - Script:6
try this
Summary
ill try that hold on. itll take a second.
wait wait lemme edit something
ok try now
the script doesnt no what plr is the server client does not know what to error script does not work.
what error you get?
didnt show error just didnt work i dont know.
also this script i gave must be a server script inside the click detector also what are you trying to click anyways
are you trying to click a gui button?
hold i think i missed typed something.
No im not trying to make a Gui, i dont know whats going on.
no im clicking a clickditector on a part.
--Veriables
local Pets = game.ReplicatedStorage.Pets
local Horse = game.ReplicatedStorage.Pets:WaitForChild("Anim")
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
local leaderstats = plr.leaderstats
local CoinStat = leaderstats:FindFirstChild("Coins")
if CoinStat then
if CoinStat.Value == CoinStat.Value + 100 then
plr.PlayerGui.MainGui.EggIcon.Visible = false
plr.PlayerGui.MainGui.EggIcon.Rotation = 9-9
plr.PlayerGui.MainGui.ImageButton.Visible = true
plr.PlayerGui.MainGui.PetImages.Cat.Visible = false
end
end
end)
in a local script inside the gui button this must work
im not inside a Gui the script is inside an clickditector im making and egg