I’m trying to make a fireball spawn when a tool is activated. The problem is when I actually publish/make the game it doesn’t actually work. Why may this be?
script.Parent.Activated:Connect(function(plr)
local debounce = false
local fire = game.ReplicatedStorage.Particles.Fire
local fireclone = fire:Clone()
local player = game.Players.LocalPlayer
local chr = player.Character
local HRP = chr.HumanoidRootPart
local part = Instance.new("Part", workspace)
part.Shape = Enum.PartType.Ball
part.Size = Vector3.new(1,1,1)
part.CFrame = HRP.CFrame * CFrame.new(0,0,10)
part.Anchored = true
part.Transparency = 1
fireclone.Parent = part
part.CanCollide = false
part.CFrame = HRP.CFrame
part.CFrame = part.CFrame * CFrame.Angles(0,0,90)
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and not hit:IsDescendantOf(player.Character) then
hit.Parent.Humanoid:TakeDamage(25)
end
end)
for i = 1,25 do
part.CFrame = part.CFrame * CFrame.new(0,0,-1)
task.wait(0.0025)
end
part:Destroy()
end)
local player = game:GetService("Players").LocalPlayer
local chr = player.Character or player.CharacterAdded:Wait()
local HRP = chr:WaitForChild("HumanoidRootPart")
local fire = game:WaitForChild("ReplicatedStorage"):WaitForChild("Fire")
script.Parent.Activated:Connect(function(plr)
local fireclone = fire:Clone()
fireclone.CFrame = HRP.CFrame * CFrame.new(0,0,-10)
fireclone.Anchored = true
fireclone.Parent = workspace
fireclone.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and not hit:IsDescendantOf(player.Character) then
hit.Parent.Humanoid:TakeDamage(25)
end
end)
for i = 1, 60 do
fireclone.CFrame = fireclone.CFrame * CFrame.new(0,0,-1)
task.wait(0.0025)
end
fireclone:Destroy()
end)