player = script.Parent.Parent.Parent.Parent.Parent cost = 500 function checkForColt() found = false for i, v in pairs(player.Backpack:GetChildren()) do if v.Name == "Colt" then found = true end end for i, v in pairs(player.Charater:GetChildren()) do if v.Name == "Colt" then found = true end end if found == true then return true else return false end end script.Parent.MouseButton1Click:connect(function() leaderstats= player:FindFirstChild("leaderstats") if leaderstats then Money = leaderstats:FindFirstChild("Points") if Money then hasColt = checkForColt() if Money.Value >= cost and hasColt == false then Money.Value = Money.Value - cost NewGun = game.Lighting.Colt:Clone() NewGun.Parent = Money.Backpack end end end end)
My leaderboard stats work fine, it out put's no errors and the colt is correctly labeled. 10+ cookiez to the guy the works it out.
You comitted several errors:
player = game.Players.LocalPlayer -- LocalPlayer, LocalScript! cost = 500 function checkForColt() found = false for i, v in pairs(player.Backpack:GetChildren()) do if v.Name == "Colt" then found = true end end for i, v in pairs(player.Charater:GetChildren()) do if v.Name == "Colt" then found = true end end if found then -- You should not put "Condition" == bool return true else return false end end script.Parent.MouseButton1Click:connect(function() leaderstats= player:FindFirstChild("leaderstats") if leaderstats then Money = leaderstats:FindFirstChild("Points") if Money then hasColt = checkForColt() if Money.Value >= cost and not hasColt then -- if you want to do a thing when a condition is false, use not. Money.Value = Money.Value - cost NewGun = game.ServerStorage.Colt:Clone() -- Why did you put the gun on Lighting???? Put it on ServerStorage - it's for that it exists. NewGun.Parent = game.Players.LocalPlayer.Backpack -- LocalPlayer, local script. end end end end)
Well, i'm not a proscripter. But try to put it inside a LocalScript instead of a normal one (I guess you used the normal one) - Do not get mad if it do not work. I tryed at least.
player = game.Players.LocalPlayer cost = 500 function checkForColt() found = false for i, v in pairs(player.Backpack:GetChildren()) do if v.Name == "Colt" then found = true end end for i, v in pairs(player.Charater:GetChildren()) do if v.Name == "Colt" then found = true end end if found then return true else return false end end script.Parent.MouseButton1Click:connect(function() leaderstats= player:FindFirstChild("leaderstats") if leaderstats then Money = leaderstats:FindFirstChild("Money") if Money then hasColt = checkForColt() if Money.Value >= cost and not hasColt then Money.Value = Money.Value - cost NewGun = game.ReplicatedStorage.Colt:Clone() NewGun.Parent = game.Players.LocalPlayer.Backpack -- LocalPlayer, local script. end end end end)
So, I've re-written, but it read's errors I don't know how to solve.
"Charater is not a valid member of player." I tried Humanoid too, but no luck. Those cookies are still up for grabs!