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

The conditions of the "if" statements were met but the code inside did not run, Why is that?

Asked by 4 years ago
function CreatingParts(name, position)
    local CreateNewPart = Instance.new("Part", workspace)
    CreateNewPart.Anchored = true   
    CreateNewPart.Position = position
    CreateNewPart.Name = name
    print("Done")
end


CreatingParts("Help", Vector3.new(4, 2.5, 43))
CreatingParts("LOL", Vector3.new(5, 2.5, 43))
CreatingParts("IHML", Vector3.new(6, 2.5, 43))
CreatingParts("HMM", Vector3.new(7, 2.5, 43))
CreatingParts("Meow", Vector3.new(8, 2.5, 43))
CreatingParts("Bomb", Vector3.new(9, 2.5, 43))
CreatingParts("Solid", Vector3.new(10, 2.5, 43))
CreatingParts("IDKWHATNAMEISHOULDGIVE", Vector3.new(11, 2.5, 43))
CreatingParts("IDK2", Vector3.new(12, 2.5, 43))
CreatingParts("IDK3", Vector3.new(13, 2.5, 43))

wait(15)
if game.Workspace.touchablepart.Touched == false then
    wait(1)
    game.Workspace.LOL.BrickColor = BrickColor.new("Really red")
elseif game.Workspace.touchablepart.Touched == true then
    workspace.LOL.BrickColor = BrickColor.new("Gold")
end

2 answers

Log in to vote
0
Answered by
SpiralRBX 224 Moderation Voter
4 years ago
Edited 4 years ago

Hi! I redid the script!

function CreatingParts(name, position)
    local CreateNewPart = Instance.new("Part", workspace)
    CreateNewPart.Anchored = true
    CreateNewPart.Position = position
    CreateNewPart.Name = name
    print("Done")
end

CreatingParts("Help", Vector3.new(4, 2.5, 43))
CreatingParts("LOL", Vector3.new(5, 2.5, 43))
CreatingParts("IHML", Vector3.new(6, 2.5, 43))
CreatingParts("HMM", Vector3.new(7, 2.5, 43))
CreatingParts("Meow", Vector3.new(8, 2.5, 43))
CreatingParts("Bomb", Vector3.new(9, 2.5, 43))
CreatingParts("Solid", Vector3.new(10, 2.5, 43))
CreatingParts("IDKWHATNAMEISHOULDGIVE", Vector3.new(11, 2.5, 43))
CreatingParts("IDK2", Vector3.new(12, 2.5, 43))
CreatingParts("IDK3", Vector3.new(13, 2.5, 43))

wait(15)
game.Workspace.touchablepart.Touched:Connect(
    function()
        wait(1)
        game.Workspace.LOL.BrickColor = BrickColor.new("Really red")
    end
)

game.Workspace.touchablepart.TouchEnded:Connect(
    function()
        workspace.LOL.BrickColor = BrickColor.new("Gold")
    end
)

TouchEnded will tell you when the part is not being touched!

Happy Scripting ^^

~~SpiralRBX

0
u gave the opposite colors but still thanks AriyanHacker29 22 — 4y
0
Oh my bad. Hope this helps! SpiralRBX 224 — 4y
0
and also why did that not work with the if statement? AriyanHacker29 22 — 4y
0
Touched is not a correct property. It has no true or false. SpiralRBX 224 — 4y
0
It is more of an event. SpiralRBX 224 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

If You Are Trying To Use The Touched Event Then This Is How It Would Work

function CreatingParts(name, position)
    local CreateNewPart = Instance.new("Part", workspace)
    CreateNewPart.Anchored = true   
    CreateNewPart.Position = position
    CreateNewPart.Name = name
    print("Done")
end

CreatingParts("Help", Vector3.new(4, 2.5, 43))
CreatingParts("LOL", Vector3.new(5, 2.5, 43))
CreatingParts("IHML", Vector3.new(6, 2.5, 43))
CreatingParts("HMM", Vector3.new(7, 2.5, 43))
CreatingParts("Meow", Vector3.new(8, 2.5, 43))
CreatingParts("Bomb", Vector3.new(9, 2.5, 43))
CreatingParts("Solid", Vector3.new(10, 2.5, 43))
CreatingParts("IDKWHATNAMEISHOULDGIVE", Vector3.new(11, 2.5, 43))
CreatingParts("IDK2", Vector3.new(12, 2.5, 43))
CreatingParts("IDK3", Vector3.new(13, 2.5, 43))

workspace.touchablepart.Touched:Connect(function(hit) -- Touched Event
wait(1) -- I Left This From Your Code
workspace.LOL.BrickColor = BrickColor.new("Really red")
wait(1) -- How Long Until It Becomes Gold
workspace.LOL.BrickColor = BrickColor.new("Gold")
end)

I Hope This Is What You Meant

0
actually, i meant to make it change color to gold when i touched the part and if i didn't then it would turn red AriyanHacker29 22 — 4y
0
Oof My Bad Harry_TheKing1 325 — 4y

Answer this question