So i have a custom toolbar and it works fine same with custom tool events BUT if a script is still running while the tool get unequipped (Move out of the character and go to a folder inside the player) every script stop midway
Here some screens also i get no errors
Local:
local Players = game:GetService("Players")
local Uis = game:GetService("UserInputService")
local Player = Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local Debounce = false
local Bind = script.Parent.Bind
local Activate = Bind:FindFirstChild("Use")
local Equipped = Bind.Equip
local Unequipped = Bind.Unequip
local Event = script.Parent.Event
Uis.InputBegan:Connect(function(Input,Obj)
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
Activate:Fire()
end
end)
Activate.Event:Connect(function()
if Debounce == false then
Debounce = true
if script.Parent:WaitForChild("Equipped").Value == true then
Event:FireServer()
end
wait(15)
Debounce = false
end
end)
Server:
local RepStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Assets = RepStorage:WaitForChild("Assets")
local Event = script.Parent:WaitForChild("Event")
local Active = false
Event.OnServerEvent:Connect(function(Player)
local Char = Player.Character
local HMR = Char.HumanoidRootPart
script.lightning_strike:Play()
local ThunderPillar = Assets:WaitForChild("ThunderPillar"):Clone()
local ThunderSphere = Assets:WaitForChild("ThunderSphere"):Clone()
ThunderPillar.Position = HMR.Position + Vector3.new(0,20,0)
ThunderSphere.Position = HMR.Position
ThunderPillar.Parent = workspace
ThunderSphere.Parent = workspace
local Info = TweenInfo.new(0.3,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,3)
local Tween = TweenService:Create(ThunderPillar,Info,{Size = Vector3.new(60,10,10), Transparency = 0})
local Tween2 = TweenService:Create(ThunderSphere,Info,{Size = Vector3.new(30,30,30), Transparency = 0})
Tween:Play()
Tween2:Play()
local Power = Instance.new("BodyVelocity")
Power.Velocity = Vector3.new(0,150,0)
Power.MaxForce = Vector3.new(0,10000000,0)
Power.Parent = HMR
wait(0.3)
Power:Destroy()
wait(0.6)
ThunderPillar:Destroy()
ThunderSphere:Destroy()
end)
Screens and gif :
https://gyazo.com/1639280ebda66ca4c2b0abd3e3514e69
Normally it should’t fly forever if it wasn’t clear