Script not working when I publish in game

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)
1 Like

Are there any errors in the console?

The script completely works in studio but not when I publish the game, it’s a local script btw. (No errors)

It does work! It’s just that my graphics quality were super low, how can I make it visible?

I played around with it.

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)

Screen Shot 2023-11-17 at 11.10.44 PM
Screen Shot 2023-11-17 at 11.10.32 PM

Fireball.rbxl (56.0 KB)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.