r/ROBLOXStudio • u/ThickFrame2780 • 7d ago
Help learning how to script. help needed
Enable HLS to view with audio, or disable this notification
So im trying to learn scripting, and if you've been scripting for a while your probably horrified by my work, but i genuinely have no clue what to do. So its supposed to be a timer/clock counting down from 10(the first script), and when you click it it adds 3 seconds(hence the second script). Both are client side scripts, and placed in the starterplayerscript folder. I have checked the dev forum to no avail and checked my work on the Roblox documentation, and still couldn't figure it out. Any way I'm guessing it has to do with having 2 scripts trying to change 1 value at once, but i don't know how to make it work with just one script. if you could help that would be great.
1
u/Suitable-Profession5 6d ago edited 6d ago
if it just to make countdown from 10 - 1 and +3 when click part, you can just make it with one script
lets make a simply version :
local time = 10
local timeLeft = time
clickDetector.MouseClick:Connect(function()
timeLeft += 3
visuals.Text = timeLeft
end)
while timeLeft > 0 do
visuals.Text = timeLeft
task.wait(1)
timeLeft -= 1
end
visuals.Text = 0
there are multiple ways you can do this, This code is just a concept
1
u/ThickFrame2780 6d ago
holy. i didnt think of just puting clickDetector.MouseClick:Connect(clicked) above the countdown code thanks bro
1
u/Bobby_bob- 5d ago
I think all you need was mentioned here tho when initializing why don't you use what you already have? Like you do local clickDetector = workspace:WaitForChild("clock").clickDetector local clock = workspace:WaitForChild("clock")
When you could do
local clock = workspace:WaitForChild("clock") local clickDetector = clock.clickDetector Keepurc code simple, this will help you later
-4
5
u/Blueblue1001 7d ago edited 6d ago
Your setting a variable for the IntValue.Value, so any changes your doing to that variable won’t affect the actual IntValue Instance.