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

How to have multiple if statements?

I'm trying to give a player all the tools if they have all the boxes checked. This isn't working.

--Aceta
local venom = game.Lighting.Venomshank
local dark = game.Lighting.Darkheart
local katana = game.Lighting.BlueKatana
local sword = game.Lighting.Sword
local debounce = true

function onTouch(hit)
	if hit.Parent then
		if hit.Parent:FindFirstChild('Humanoid')and debounce == true then
			debounce = false
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			character = hit.Parent
			character.Torso.CFrame = CFrame.new(Workspace.teleportation.Position+Vector3.new(math.random(1,10),math.random(1,10),math.random(1,10)))
			sword:Clone().Parent = player.Backpack
		
			if player.Venomshank.Value == true then
				venom:Clone().Parent = player.Backpack
			elseif player.Darkheart.Value == true then
				dark:Clone().Parent = player.Backpack
			elseif player.BlueKatana.Value == true then
				katana:Clone().Parent = player.Backpack
			end
			debounce = true
		end
	end
end
script.Parent.Touched:connect(onTouch)

3 comments

0

Output?

0

None. It just gives the player one weapon instead of all.

0

Aceta I fixed it.

2 answers

if player.Venomshank.Value==true then
if player.Darkheart.Value==true then
 if player.BlueKatana.Value==true then
venom:Clone().Parent=player.Backpack
dark:Clone().Parent=player.Backpack
katana:Clone().Parent=player.Backpack
       Nested IF statements, This should work thanks for being on spot with the problem.
--Hyb^
function venomshank()
local venom = game.Lighting.Venomshank
local dark = game.Lighting.Darkheart
local katana = game.Lighting.BlueKatana
 if _G.player.Venomshank.Value == true then
                venom:Clone().Parent = _G.player.Backpack
end
end

function dh()
local venom = game.Lighting.Venomshank
local dark = game.Lighting.Darkheart
local katana = game.Lighting.BlueKatana
            if _G.player.Darkheart.Value == true then
                dark:Clone().Parent = _G.player.Backpack
end
end

function blue_katana()
local venom = game.Lighting.Venomshank
local dark = game.Lighting.Darkheart
local katana = game.Lighting.BlueKatana
if _G.player.BlueKatana.Value == true then
            katana:Clone().Parent = _G.player.Backpack
end
end

local venom = game.Lighting.Venomshank
local dark = game.Lighting.Darkheart
local katana = game.Lighting.BlueKatana
local sword = game.Lighting.Sword
local debounce = true
local num = {1, 10}
local x = math.random(1, #num)

function onTouch(hit)
    if hit.Parent then
        if hit.Parent:FindFirstChild('Humanoid') and debounce == true then
            debounce = false
		_G.player = game.Players[hit.Parent.Name]
            character = hit.Parent
            character:MoveTo(Workspace.teleportation.Position+Vector3.new(num[x],num[x],num[x]))
       sword:Clone().Parent = _G.player.Backpack
venomshank()
dh()
blue_katana()
            debounce = true
        end
    end
end
script.Parent.Touched:connect(onTouch)

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