Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My clickdetector shop isn't working and isn't giving an error?

Asked by 7 years ago

I'm trying to make a part with a clickdetector on it that sells a Katana for 7 KOs at my game. This isn't working and I'm not receiving an error. Any ideas on how to fix this?

local player = game.Players.LocalPlayer
local clickdetector = script.Parent:WaitForChild("ClickDetector")
local sword = game.ServerStorage:WaitForChild("Katana")

clickdetector.MouseClick:connect(function()
    if player.leaderstats.KOs.Value >= 7 then
        player.leaderstats.KOs.Value = player.leaderstats.KOs.Value - 7
        local sword1 = sword:Clone()
        sword1.Parent = player.Backpack
        local sword2 = sword:Clone()
        sword2.Parent = player.StarterGear
    end
end)
0
Assuming this is in a LocalScript? ClickDetectors do not work in localscripts. Thundermaker300 554 — 7y
0
Also LocalScripts cannot access ServerStorage. Thundermaker300 554 — 7y
0
Oh that's why lol mrsbigballz 8 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Local scripts can't access server storage, make it a normal script. Please accept my answer, if i am right.

Ad

Answer this question