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

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

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

✓ Accepted answer

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

5 comments

0

u gave the opposite colors but still thanks

0

Oh my bad. Hope this helps!

0

and also why did that not work with the if statement?

0

Touched is not a correct property. It has no true or false.

0

It is more of an event.

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

2 comments

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

0

Oof My Bad

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