Tool giver script broken?

local tool = game.ServerStorage.Axe
local part = script.Parent

clickDet.MouseClick:Connect(function(p)
	
	local toolClone = tool:Clone()
	toolClone.Parent = p.Backpack
	
	clickDet:Destroy()

	repeat
		part.Transparency = part.Transparency + .1
		wait(.1)
	until part.Transparency == 1
end)

My goal is to make a bag that gives an axe when clicked on and it also disappears after clicked. Originally, it worked fine, but now it doesn’t do anything! No errors.

Storing things in Lighting is not supported.


Print-check a bit and tell us what happens. If the prints stop coming at some point, then you know where your script is broken.

How about you add a click detector to a part, and try out this script, it’s always worked for me. local

Detector = script.Parent.ClickDetector
local Tool = game.ServerStorage.(Tool)
local Part = script.Parent

Detector.MouseClick:Connect(function(Player)
local Clone = Tool:Clone()
Clone.Parent = Player.Character
Part:Destroy()
end)

I typed it wrong, Local is part of it.

I don’t know if you didn’t even try what I said, but it works very well, just as I said it would.

script.Parent.ClickDetector.MouseClick:connect(function(player)
	local backpack = player.Backpack
	local tool = game.Lighting.Axe
	tool:Clone().Parent = backpack
end)

From what I can see, you never made a local for clickDet.

Add this to the top of your script:

local clickDet = script.Parent.ClickDetector

If you named your ClickDetector clickDet, then add this to the top instead:

local clickDet = script.Parent.clickDet

From my calculations, he wants to make it so the tool giver disappears after a player clicks on it whilst giving the tool to the player, but what i’m confused about is if he wants it to be client (only for player) or server (for everyone).

I’m also thinking if he wants to make it so it’ll appear again if the player who clicked on it and got the tool died and lost the tool.

Try destroying the click detector after the repeat statement. If that doesnt work, simply turn off CanColide via CanColide = false and then set transparency to 0.

Crap I didn’t put the clickdet part in, sorry!

I want it to be for everyone, but I know that RemoteEvents should only be triggered by GUIs or SurfaceGui Buttons. It should also give the player the axe, but thats the only thing it doesnt do.

I said that I already added it to the top.