Hello All, so today i was looking through old scripts and i saw a time position script. It looked pretty messy so i TRIED to remake it but i ended up with this
local playersStarterPark = game.Players.LocalPlayer.Character
local characterTool = playersStarterPark:FindFirstChildWhichIsA("Tool")
local sound = characterTool.ugh
local label = script.Parent.TIme
characterTool.Equipped:Connect(function()
label.Text = string.format("%d:%02d", math.floor(sound.TimePosition/60), sound.TimePosition%60)
end)
doesn’t even work lol. I seriously need help on this
Could we please have more context into what the hell your doing.
As of right now, we don’t even know what your problem is, nonetheless what the table sound is supposed to represent / hold
like i said, i don’t know im being insanely dumb right now. im trying to make when a text label replicates how long the song has been going for. i apologize for you not understanding, hope this clears it
local playersStarterPark = game.Players.LocalPlayer.Character
local characterTool = playersStarterPark:FindFirstChildWhichIsA("Tool")
local sound = characterTool.ugh
local label = script.Parent.TIme -- Is that what it's named?
while task.wait(1) do -- Ik, bad practice, sue me.
label.Text = string.format("%d:%2d", math.floor(sound.TimePosition / 60), sound.TimePosition%60)
end
In theory, this should work!
You could also do this:
local runService = game:GetService("RunService")
local playersStarterPark = game.Players.LocalPlayer.Character
local characterTool = playersStarterPark:FindFirstChildWhichIsA("Tool")
local sound = characterTool.ugh
local label = script.Parent.TIme -- Is that what it's named?
runService.Heartbeat:Connect(function()
label.Text = string.format("%d:%2d", math.floor(sound.TimePosition / 60), sound.TimePosition%60)
end)
(I have no freaking idea if Heartbeat is the right one, otherwise, it’s RenderStepped. But I think it is Heartbeat!)
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local label = script.Parent.Label
character.ChildAdded:Connect(function(tool: Tool)
if tool:IsA("Tool") then
label.Text = string.format("%d:%2d", math.floor(tool.ugh.TimePosition / 60), tool.ugh.TimePosition%60)
end
end)