I have a Part that when a player touches it, gets a random item. That works completely fine if the Part is in the workspace. If the Part is cloned from ReplicatedStorage, the script does not function at all and leaves no errors in the output. When the Part is cloned, it has the correct scripts in it. I’ve tried to adjust the script but nothing seems to be working
local rs = game:GetService("ReplicatedStorage")
game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(c)
script.Parent.Touched:Connect(function(object)
if object.Parent:findFirstChild("Humanoid")~=nil then
local m = math.random(1, 3)
if m == 1 then
local tool1 = rs.forcefield:Clone()
tool1.Parent = p:FindFirstChild("Backpack")
script.Parent:Destroy()
elseif m == 2 then
local tool2 = rs["hologram sword"]:Clone()
tool2.Parent = p:FindFirstChild("Backpack")
script.Parent:Destroy()
elseif m == 3 then
local tool3 = rs.glasses:Clone()
tool3.Parent = p:FindFirstChild("Backpack")
script.Parent:Destroy()
end
end
end)
end)
end)