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

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

Asked by 8 years ago
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?

0
Where is Line 65 on your script? Also, what is RPSDT, RPSCopy and RPSMT? Spongocardo 1991 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

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.

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! Arithmeticity 167 — 8y
Ad

Answer this question