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

If player dies the script doesn't run?

Asked by 5 years ago

When a player dies in game, the script no longer works. Before the player dies everything seems fine but when they die, it wont work. There's no output either. I looked through my script and found nothing. Someone help.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local remote = game.ReplicatedStorage.TeleRemote
local remoted = game.ReplicatedStorage.TeleRemoteD
local mtarget
local mtarget2
local down
local partic
local f4
local attach0
local attach1
beam = game.ReplicatedStorage.TeleBeam
local cool = true
game.StarterPack.LocalScript.Value.Name = player.Name


mouse.Button2Down :connect(function()
    --if game.ReplicatedStorage.Mana.Value < 20 then return end 
    if cool == true then
        remote:FireServer()
        mtarget2 = game.Workspace.Tele
        attach0 = mtarget2.TeleAttachment
        attach1 = player.Character.RightHand.RightGripAttachment
        down = true
        mtarget2.ParticleEmitter.Enabled = true
        beam.Attachment0 = attach0
        beam.Attachment1 = attach1
        beam.Parent = attach1.Parent
    end
end)

mouse.Move:Connect(function()   
    if down == true then 
        local posX,posY,posZ = mouse.Hit.X,mouse.Hit.Y,mouse.Hit.Z
        mtarget2.CFrame = CFrame.new(posX,posY,posZ)
    end
end)

mouse.Button2Up:connect(function()
    if cool == true then
        if down == true then
        game.ReplicatedStorage.Mana.Value = game.ReplicatedStorage.Mana.Value - 0
        cool = false
        remoted:FireServer()
        f4 = game.ReplicatedStorage.ParticleEmitter2:Clone()
        mtarget = player.Character.HumanoidRootPart
        local posX,posY,posZ = mouse.Hit.X,mouse.Hit.Y,mouse.Hit.Z
        mtarget.CFrame = CFrame.new(posX,posY,posZ) + Vector3.new(0,3,0)
        down = false
        mtarget2.ParticleEmitter.Enabled = false
        beam.Parent = game.ReplicatedStorage
        cool = true
        end
    end
end)
0
When I have these types of issues, I usually add a wait(0.5) on line one of the script. It allows the client to load all other resources before it load all our variables. benben3963 6 — 5y
0
^ This didn't work for me. User#22996 0 — 5y
0
well this is a local script which is getting parented to the playergui or backpack when te game is running, so its probarly cuz when the player dies this script is gone, but it should respawn starmaq 1290 — 5y
0
oh User#22996 0 — 5y
0
Script is still in backpack when player dies but it's not running. User#22996 0 — 5y

Answer this question