I'm trying to make a fireball script for my game, I connected the playerss mouseclick function to firing this event. This works better than I had hoped for in studio, but the fireball doesn't show up in the real game.
game.Players.PlayerAdded:Connect(function(plr)
wait(1)
local fireballEvent = game.ReplicatedStorage.ThrowFireball
fireballEvent.OnServerEvent:Connect(function(player, mouse)
local fb = game.ServerStorage.Fireball:Clone()
fb.Parent = game.workspace:FindFirstChild(plr.Name)
fb.CanCollide = false
fb.Position = game.workspace:FindFirstChild(plr.Name).UpperTorso.Position
local bv = Instance.new("BodyVelocity", fb)
bv.Velocity = mouse.lookVector * 50
bv.P = Vector3.new(math.huge,math.huge,math.huge)
fb.Touched:Connect(function(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
local eHum = nil
if h and not hit.Parent.Name == player.Name then
eHum:TakeDamage(10)
local eHum = hit.Parent.Humanoid
end
end)
game:GetService("Debris"):AddItem(fb, 10)
end)
end)
Thanks in advance for helping me find the error. -Cmgtotalyawesome
