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

Why doesn't this script work? Should just find if a tool exists in player's backpack.

if game.Players.LocalPlayer.Backpack:FindFirstChild("RPSCopy") == nil and game.Players.LocalPlayer.Backpack:FindFirstChild("RPSDT") == nil and game.Players.LocalPlayer.Backpack:FindFirstChild("RPSMT") == nil then 
RPSCopy:clone().Parent = game.Players.LocalPlayer.Backpack;
RPSDT:clone().Parent = game.Players.LocalPlayer.Backpack;
RPSMT:clone().Parent = game.Players.LocalPlayer.Backpack;
end
end

Yes I have all of those variables/names defined.

ERROR:

20:34:25.029 - Players.Player.PlayerGui.rBuild_UI.Navigation_Gamebar.Navig:65: attempt to index local 'RPSDT' (a function value)

Why?

1 comment

0

Where is Line 65 on your script? Also, what is RPSDT, RPSCopy and RPSMT?

1 answer

✓ Accepted answer

You can't create and parent clones in the same line: You need to define them as variables and then parent them, or they will be eaten up by the merciless garbage collector. Additionally, you have two ends when there should only be one.

Here's how I'd do it:

local player = game.Players.LocalPlayer
local backpack = player.Backpack

if not (backpack:FindFirstChild("RPSCopy") and backpack:FindFirstChild("RPSDT") and backpack:FindFirstChild("RPSMT")) then

local a = RPSCopy:Clone()
local b = RPSDT:Clone()
local c = R{SMT:Clone()

a.Parent = backpack
b.Parent = backpack
c.Parent = backpack

end

If that's not the case, then you might've named a function in that script "RPSDT" or something.

1 comment

0

Thanks. I took a quick glance at this and re-did my script and I found out that I had something like game.Workspace.Destroy and it took that as a function (not exactly but LIKE.) So don't do that guys and thank you so much!

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