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

How to have multiple if statements?

Asked by 9 years ago

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)
0
Output? Perci1 4988 — 9y
0
None. It just gives the player one weapon instead of all. RedneckBane 100 — 9y
0
Aceta I fixed it. Hybric 271 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
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.
Ad
Log in to vote
-1
Answered by
Hybric 271 Moderation Voter
9 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
--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)

Answer this question