So, i'm working on a zombie survival game and i'm working on scripting the weapon pickups, but when I click the part that the script and ClickDetector is in, it doesn't do anything, even when I set points to over 800. And it worked fine without me trying to set a price in "Points" (the currency of the game)
local Points = game.ServerScriptService.leaderboard.leaderstats.Points --I have a leaderboard script that keeps track of what wave you're on and how many points you have function hi(x) if Points >799 then local y = x.Backpack local z = game.ReplicatedStorage["AK47"] --Changes the tool that it gives, I have tested without adding the points and it gave me the weapon if wait() then Points = Points - 800 end z:Clone().Parent = y end script.Parent.ClickDetector.MouseClick:connect(hi)
.Value
if Points
is a ValueBase
. Also please indent your code correctly, it is extremely messy and cannot be read.local ServerScriptService = game:GetService("ServerScriptService") local Points = ServerScriptService.leaderboard.leaderstats.Points --I have a leaderboard script that keeps track of what wave you're on and how many points you have local function hi(x) -- use local functions if Points.Value >= 800 then--check the value! local y = x.Backpack local z = game.ReplicatedStorage["AK47"] --Changes the tool that it gives, I have tested without adding the points and it gave me the weapon Points.Value = Points.Value - 800--subtract the value! z:Clone().Parent = y end end script.Parent.ClickDetector.MouseClick:Connect(hi) -- connect is deprecated, use Connect