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

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

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?

1 comment

0

Try putting lines 6-7 in the localscript into the OnClientEvent function.

1 answer

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

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