#i dont get what im doing wrong here

1 messages · Page 1 of 1 (latest)

pseudo stone
#

hey everyone im new to luau here and im trying to learn more about tools , im trying to make it where if a tool is unequipped the code that runs Stops. but i dont get what im doing wrong here , i just need someone to explain this for me i have already searched this up a lot of times on google and i still cant find the solution to this , any help will be appreciated.

woven bridge
#

you dont need an if before the tool.unequipped

#

also the while false do seems useless

pseudo stone
#

oh yeah i see it now

woven bridge
#

yeah while false do just does literally nothing

pseudo stone
#

ok hold on let me try the code

#

Doesnt work

woven bridge
#

oh yeah setting a part's brickcolor to nil will just bug out

pseudo stone
woven bridge
#

would still not work

#

you need to give it a color

#

you cant just not give it one

#

if you want it to be pitch black then make it pitch black

pseudo stone
#

ok hold on

astral tapir
pseudo stone
astral tapir
pseudo stone
astral tapir
pseudo stone
#

local UIS = game:GetService("UserInputService")

local endermanAudio = script.Parent.endermanSound
local Part = script.Parent.Parent.idk
local tool = script.Parent.Parent.Parent.PickTool

function PlayAudio()
endermanAudio:Play()
end

UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
while true do
task.wait(0.35)
PlayAudio()
Part.BrickColor = BrickColor.random()

    end    
end    

end)

tool.Unequipped:Connect(function()
Part.BrickColor = Color3.fromRGB(255,0,0) -- Red colour
PlayAudio:Stop()
end)

astral tapir
# pseudo stone local UIS = game:GetService("UserInputService") local endermanAudio = script.Pa...
local UIS = game:GetService("UserInputService")

local endermanAudio = script.Parent.endermanSound
local Part = script.Parent.Parent.idk
local tool = script.Parent.Parent.Parent.PickTool

local stopRunning = false

UIS.InputBegan:Connect(function(input, GPE)
    if GPE then return end
    stopRunning = false

    if input.UserInputType == Enum.UserInputType.MouseButton1 then

        while not stopRunning do
            task.wait(0.35)
            endermanAudio:Play()
            Part.BrickColor = BrickColor.random()
        end
    end

end)

tool.Unequipped:Connect(function()
    stopRunning = true
    Part.BrickColor = BrickColor.new("Really Red") -- Red colour
    endermanAudio:Stop()
end)
cosmic nicheBOT
#

studio** You are now Level 7! **studio

astral tapir
astral tapir
pseudo stone
astral tapir
# pseudo stone Yes

Part.BrickColor = BrickColor.new("Really Red") also, stopRunning should be set inside the if statement not outside it mb

pseudo stone
astral tapir
# pseudo stone u want me to put if before stopRunning?

like this

local UIS = game:GetService("UserInputService")

local endermanAudio = script.Parent.endermanSound
local Part = script.Parent.Parent.idk
local tool = script.Parent.Parent.Parent.PickTool

local stopRunning = false

UIS.InputBegan:Connect(function(input, GPE)
    if GPE then return end

    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        stopRunning = false

        while not stopRunning do
            task.wait(0.35)
            endermanAudio:Play()
            Part.BrickColor = BrickColor.random()
        end
    end

end)

tool.Unequipped:Connect(function()
    stopRunning = true
    Part.BrickColor = BrickColor.new("Really Red") -- Red colour
    endermanAudio:Stop()
end)
pseudo stone
astral tapir
pseudo stone
#

i guess i'll do that

cobalt idol
pseudo stone
#

it works

cobalt idol
#

alr ok

#

bye!