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

Pickup Script stops working if a Player is killed/resets?

Asked by 6 years ago

So no output errors. Not sure why this is happening. Basically you click a click detector and it clones to your backpack. It all works fine but if you die, it will no longer work. As in the gun will disappear but will not clone.

ServerScript(In gun):

local cd = script.Parent.ClickDetector
local rep = game:GetService("ReplicatedStorage")
local gun = rep.Guns:WaitForChild(script.Parent.Parent.Name)

cd.MouseClick:connect(function(player)
    rep.Rf.mog:FireClient(player)
    script.Parent.Parent:Destroy()
end)

cd.MouseHoverEnter:connect(function()
    script.Parent.Transparency = 0.9
end)

cd.MouseHoverLeave:connect(function()
    script.Parent.Transparency = 1
end)

LocalScript(In PlayerScripts):

local players = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")

local player = players.LocalPlayer
local Rems = rep.Rf
local back = player:WaitForChild("Backpack")
local snd = player.PlayerGui.Sounds

Rems.mog.OnClientEvent:Connect(function()
    local gc = rep.Guns:WaitForChild("M1Garand"):Clone()
    gc.Parent = back
end)

Any help? Or something I do no longer available when the player resets?

0
Try putting lines 6-7 in the localscript into the OnClientEvent function. User#20279 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Did you cloned the gun or moved the gun to another parent?

Ad

Answer this question