Hello, here I have my upgraded instant campfire script and was wondering where to put a "wait ()" to make the player wait before they can use it again? I have my own asset so that will not be the problem.
local Tool = script.Parent local CurrentCampfire = Tool:WaitForChild('CurrentCampfire') local Mouse = nil local InsertService = game:GetService('InsertService') local CAMPFIRE_ASSET_ID = 0 local SMALL_OFFSET = Vector3.new(0, 1, 0) local LARGE_OFFSET = Vector3.new(0, 1500, 0) local function OnActivated() if Mouse then local character = Tool.Parent if character then local humanoid = character:FindFirstChild('Humanoid') if humanoid and not humanoid.Sit then local hitLocation = Mouse.Hit local previousCampfire = CurrentCampfire.Value if previousCampfire then previousCampfire:Remove() end local campfire = InsertService:LoadAsset(CAMPFIRE_ASSET_ID):GetChildren()[1] CurrentCampfire.Value = campfire campfire.Parent = Workspace humanoid.Died:connect(function() campfire:Destroy() end) campfire:MoveTo(hitLocation.p + SMALL_OFFSET) Tool.Handle.Drop:Play() end end end end local function OnEquipped(mouse) if mouse then Mouse = mouse end end local function OnUnequipped() end Tool.Activated:connect(OnActivated) Tool.Equipped:connect(OnEquipped) Tool.Unequipped:connect(OnUnequipped)
Adding a single delay will not prevent OnActivated
from running a second time. You need to add a variable and make sure that it is true before executing the rest of the function, set it to false when it is run, and then after a delay, set it back to true.