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

How to make my script only if work if the tools aren't in the person inventory?

function hi(x)
local y = x.Backpack
local z = game.Lighting["Dragon Slayer"]
z:Clone().Parent = y -- then put your item in lightning.
end

script.Parent.ClickDetector.MouseClick:connect(hi)

So this is my code above... how would I fix this so that if the tool that is being given is already in the person inventory not be given otherwise if they don't have the tool it will be given?

1 comment

0

I tried something like if not player.Backpack:FindFirstChild("Dragon Slayer" ) then if not char:FindFirstChild("Dragon Slayer") then

2 answers

function hi(Plr)
local Lighting = game:GetService("Lighting")
local Backpack = Plr.Backpack
local DS = Lighting["Dragon Slayer"]:Clone()
DS.Parent = Backpack
end

script.Parent.ClickDetector.MouseClick:Connect(hi(Player))

1 comment

0

He said if there is no tool in the backpack. This doesn't solve his problem

You should use "if statements"

local  z =  game.Lighting["Dragon Slayer"]
if x.BackPack:FindFirstChild(z) then
print("has")
end
else z:Clone().Parent =  x.BackPack
end

2 comments

0

can u rewrite so it works as a function

0

you should put else before the end

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