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

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

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

0
I tried something like if not player.Backpack:FindFirstChild("Dragon Slayer" ) then if not char:FindFirstChild("Dragon Slayer") then itadakimasu_Kurepu 29 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

```lua 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)) ```

0
He said if there is no tool in the backpack. This doesn't solve his problem JuuzouBlitz 75 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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
0
can u rewrite so it works as a function itadakimasu_Kurepu 29 — 5y
0
you should put else before the end Imperialy 149 — 5y

Answer this question