local holding = false
local tweenservice = game:GetService("TweenService")
--SETTINGS
local range = script.Parent.STATS.Range
local multiplier = script.Parent.STATS.Multiplier
local tool = script.Parent
local db = true
task.spawn(function()
tool.Unequipped:Connect(function()
holding = false
print(holding)
end)
end)
tool.Equipped:Connect(function()
holding = true
local player = game.Players:FindFirstChild(script.Parent.Parent.Name)
local HRP = script.Parent.Parent.HumanoidRootPart
repeat
if db == false then
task.wait(2)
end
task.wait(0.05)
for _,Coin in pairs(workspace:GetPartBoundsInBox(script.Parent.Handle.CFrame,Vector3.new(range.Value,range.Value,range.Value))) do
if Coin.Name == "Coin" or Coin.Name == "Diamond" then
if player.leaderstats.Zones[Coin.Zone.Value].Value == true and Coin.Picked.Value == false then
task.spawn(function()
if holding == false then return end
Coin.Picked.Value = true
Coin.Owner.Value = script.Parent.Parent.Name
local beam1,beam2 = game.ReplicatedStorage.beams.Basic:Clone(), game.ReplicatedStorage.beams.Basic:Clone()
beam1.Parent = script.Parent.Handle.Tips.beam1
beam1.Attachment0 = script.Parent.Handle.Tips.beam1
beam1.Attachment1 = Coin.beamAttachment
beam2.Parent = script.Parent.Handle.Tips.beam2
beam2.Attachment0 = script.Parent.Handle.Tips.beam2
beam2.Attachment1 = Coin.beamAttachment
if player.leaderstats.Stats.backpack and Coin.Name == "Coin" then
player.leaderstats.Stats.backpack.Value += Coin.Worth.Value * (multiplier.Value + player.leaderstats.Stats.Multiplier.Value)
elseif player.leaderstats.diamonds and Coin.Name == "Diamond" then
player.leaderstats.diamonds.Value += Coin.Worth.Value * (multiplier.Value + player.leaderstats.Stats.Multiplier.Value)
end
tween = tweenservice:Create(Coin,TweenInfo.new(1,Enum.EasingStyle.Exponential),{
Orientation = HRP.Orientation,
Position = script.Parent.Handle.Collect.WorldPosition,
Transparency = 1
}):Play()
task.spawn(function()
print(Coin.Name)
print(holding)
task.wait(0.2)
Coin:Destroy()
beam1:Destroy()
beam2:Destroy()
end)
end)
end
end
end
until holding == false
db = false
task.wait(1)
db = true
end)
https://gyazo.com/458afd87d15a50d9a19bad9cf8d246dd
This is what i want to happen^
and sometimes it just fires like way later and alot of stuff breaks, i’m confused as to why