Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

3 comments

0

Assuming this is in a LocalScript? ClickDetectors do not work in localscripts.

0

Also LocalScripts cannot access ServerStorage.

0

Oh that's why lol

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.