Trying to make this script limit the player to only getting one of the tools.
Any help?
local tool = game.ServerStorage["Pickaxe"]
local giver = script.Parent
local canGive = false
local function GiveTool (player)
if canGive == false then
local clone = tool:Clone()
clone.Parent = player.Backpack
wait(1)
canGive = false
end
end
giver.ClickDetector.MouseClick:Connect(function(player)
GiveTool(player)
end)
local tool = game.ServerStorage["Pickaxe"]
local giver = script.Parent
local canGive = false
local function GiveTool (player)
if canGive == true then
local clone = tool:Clone()
clone.Parent = player.Backpack
wait(1)
canGive = false
end
end
giver.ClickDetector.MouseClick:Connect(function(player)
GiveTool(player)
end)
all you have to do hear is swap the “canGive == false” with “canGive == true” in your if statement, and hopefully it should work
local tool = game.ServerStorage["Pickaxe"]
local giver = script.Parent
local canGive = false
local function GiveTool (player)
if canGive == true then
local clone = tool:Clone()
clone.Parent = player.Backpack
canGive = false
end
end
giver.ClickDetector.MouseClick:Connect(GiveTool)
Hmmm… I seem to be getting 'Infinite yield possible on ‘Workspace.DelovilleMiner:WaitForChild(“ForceField”)’" when i try this
Not sure how the ForceField is related but i have it disabled through a script
Although this topic is already solved, there is another solution which is disconnecting the connection; something like this would work. This is pseudocode
local connection
connection = giver.ClickDetector.MouseClick:Connect(function()
tool:Clone().Parent = ["PARENT"]
connection:Disconnect()
end)