local touchp = game.Workspace.touchpart
local color = 0
touchp.Touched:Connect(function()
touch = true
end)
touchp.TouchEnded:Connect(function()
touch = false
end)
while true do
while touch do
touchp.Color = Color3.fromHSV(color, 1, 1)
task.wait(0.05)
color = color + 0.01
if color >= 1 then
task.wait(0.05)
color = 0
end
end
end ```
It's a normal script sitting in ServerScriptService but I can't see it doing anything in game
#can someone help me with my code?
1 messages · Page 1 of 1 (latest)
well first, add a print statment in the second while loop to ensure its running, then another in the if statment
then if you get prints you can check for other issues
will do
"Script timeout, exhausted allowed execution time"
so the wait in between the colour changes has to be longer no?
no because you have a while loop with no wait
do this
local touch = false
local touchp = game.Workspace.touchpart
local color = 0
touchp.Touched:Connect(function()
touch = true
end)
touchp.TouchEnded:Connect(function()
touch = false
end)
while touch do
touchp.Color = Color3.fromHSV(color, 1, 1)
task.wait(0.05)
color = color + 0.01
if color >= 1 then
task.wait(0.05)
color = 0
end
end
now there is only one while loop
Add a yield like task.wait()
in the if statement or the loop
And also place this on a function
Loop
should i add a continue#
** You are now Level 1! **
why would i is it not a loop
You can literally use functions on a loop
local touchp = game.Workspace.touchpart
local color = 0
touchp.Touched:Connect(function()
touch = true
end)
touchp.TouchEnded:Connect(function()
touch = false
end)
local function hi()
while touch do
touchp.Color = Color3.fromHSV(color, 1, 1)
task.wait(0.05)
color = color + 0.01
if color >= 1 then
task.wait(0.05)
color = 0
end
task.wait(0.05)
end
end
while true do
hi()
end```
sorry if i misunderstood something im still quite new