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.
#i dont get what im doing wrong here
1 messages · Page 1 of 1 (latest)
you dont need an if before the tool.unequipped
also the while false do seems useless
yeah while false do just does literally nothing
Thanks for pointing that out
ok hold on let me try the code
Doesnt work
oh yeah setting a part's brickcolor to nil will just bug out
so i set to false?
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
tool.Unequipped:Connect(function()
Part.BrickColor = "Really Red"
PlayAudio:Stop()
end)
it doesnt work
hold on i'll show entire script
somethings probably wrong with your varaibles then
how can i fix them
are you able to psate the code into here instead
Ok sure
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)
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)
** You are now Level 7! **
What does gpe mean?
game processed event, so if your were tyring to click the chatbar or sum, it wont run
Oh i see
Omg it works thank u so much
thats good do u understand it tho
Yes
Part.BrickColor = BrickColor.new("Really Red") also, stopRunning should be set inside the if statement not outside it mb
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)
wheres the difference, i've been looking at both scripts
i edited the msg
is it working?