Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
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)

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. SprinkledFruit101 135 — 4y
0
I am glad to elaborate if you want me to. SprinkledFruit101 135 — 4y
0
Read up on FilteringEnabled virushunter9 943 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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
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 JustPapi 49 — 4y
0
and it is also having problems with humanoid JustPapi 49 — 4y
Ad

Answer this question