Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my FireBall invisible to other players but visible to me??

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local char = plr.Character or plr.CharacterAdded:wait()
local fireball = game.ReplicatedStorage.FireBending.Fire1
local canattack = true
local checkdeath = true

mouse.KeyDown:connect(function(key)
	if key == "z" and canattack == true then
		
		canattack = false
		
		local fire = fireball:Clone()
		fire.Parent = workspace
		fire.CFrame = char.Humanoid.Torso.CFrame * CFrame.new(0,0,-10)
		
		local bodyv = Instance.new("BodyVelocity")
		bodyv.MaxForce = Vector3.new(1e8,1e8,1e8)
		bodyv.Velocity = char.Humanoid.Torso.CFrame.lookVector * 150
		bodyv.Parent = fire
		
		local fireanim1 = char.Humanoid:LoadAnimation(script.FireAnim1)
		local fireanim2 = char.Humanoid:LoadAnimation(script.FireAnim2)
		local fireanim3 = char.Humanoid:LoadAnimation(script.FireAnim3)
		local choose = math.random(1,3)
		if choose == 1 then
			fireanim1:Play()
		elseif choose == 2 then
			fireanim2:Play()
		elseif choose == 3 then
			fireanim3:Play()
		end
		
		
		wait(2)
		fire:remove()
		wait(1)
		canattack = true
		
	end
end)

while checkdeath == true do
	wait(.1)
	if plr.Character.Humanoid.Health <= 0 then
		script:remove()
	end
end

The code at the top is the local script for my fireball and seems to work just fine Its just that whenever I hop in my game to test with my friend he can't see the fireball and I can't see his Does anyone know how to fix? (Animations work just fine)

3 comments

0

I think it is the fact that you are using it in a local script, what you want to do is fire a remote event in the local script and then use the script that makes the fireball appear in the server script instead.

0

I am glad to elaborate if you want me to.

0

Read up on FilteringEnabled

1 answer

The reason it shows up to you only is that it's on the client, not on the server. You'll need to use RemoteEvents and fire it upon the MouseKeyDown function. Add a RemoteEvent in ReplciatedStorage and copy what I do.

Local script:

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local char = plr.Character or plr.CharacterAdded:wait()
local fireball = game.ReplicatedStorage.FireBending.Fire1
local canattack = true
local checkdeath = true

mouse.KeyDown:connect(function(key)
    if key == "z" and canattack == true then
        game.ReplicatedStorage.RemoteEvent:FireServer() -- Fires the RemoteEvent
      end
end)

Now, add a script into ServerScriptService:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)

local mouse = plr:GetMouse()
local char = plr.Character or plr.CharacterAdded:wait()
local fireball = game.ReplicatedStorage.FireBending.Fire1
local canattack = true
local checkdeath = true

        canattack = false
        local fire = fireball:Clone()
        fire.Parent = workspace
        fire.CFrame = char.Humanoid.Torso.CFrame * CFrame.new(0,0,-10)

        local bodyv = Instance.new("BodyVelocity")
        bodyv.MaxForce = Vector3.new(1e8,1e8,1e8)
        bodyv.Velocity = char.Humanoid.Torso.CFrame.lookVector * 150
        bodyv.Parent = fire

        local fireanim1 = char.Humanoid:LoadAnimation(script.FireAnim1)
        local fireanim2 = char.Humanoid:LoadAnimation(script.FireAnim2)
        local fireanim3 = char.Humanoid:LoadAnimation(script.FireAnim3)
        local choose = math.random(1,3)
        if choose == 1 then
            fireanim1:Play()
        elseif choose == 2 then
            fireanim2:Play()
        elseif choose == 3 then
            fireanim3:Play()
        end


        wait(2)
        fire:remove()
        wait(1)
        canattack = true

    end
end)

while checkdeath == true do
    wait(.1)
    if plr.Character.Humanoid.Health <= 0 then
        script:remove()
    end
end

2 comments

0

When I put the script in it says the serverscript "attempt to index nil with 'Clone'" and it won't work. And I can't use the move without the actual fireball

0

and it is also having problems with humanoid

This discussion is preserved as it was. New answers, comments, and votes are closed.