So, me and a friend are making a game and im trying to make a Time counter. The time counter works fine but then i tried to make a script that shows the best time in the server in a gui by using a number value. But the value wont change. The Scripts: Local Script:
game:WaitForChild("ReplicatedStorage"):WaitForChild("RemoteEvents"):WaitForChild("ValueChanger")
game:WaitForChild("ReplicatedStorage"):WaitForChild("RemoteEvents"):WaitForChild("BestTimeRemote")
local Active = false
local Debounce = false
local localPlayer = game.Players.LocalPlayer
local localCharacter = localPlayer.Character
local TogglePart = workspace:WaitForChild("StartPart")
local EndTogglePart = workspace:WaitForChild("EndPart")
local DiePart = workspace:WaitForChild("DiePart")
local Counter = 0.1
TogglePart.Touched:Connect(function(partTouched)
if partTouched.Parent.Name == game.Players.LocalPlayer.Name then
Counter = 0.1
if Debounce == false then
Debounce = true
if Active == true then
return
end
Active = true
spawn(function()
while Active do
wait(0.1)
game.Players.LocalPlayer.PlayerGui.TimerScreenGui.TimerFrame.TimerTextLabel.Text = Counter
Counter = game.Players.LocalPlayer.PlayerGui.TimerScreenGui.TimerFrame.TimerTextLabel.Text + 0.1
end
end)
wait(1)
Debounce = false
end
end
end)
EndTogglePart.Touched:Connect(function(endPartTouched)
if endPartTouched.Parent.Name == game.Players.LocalPlayer.Name then
Active = false
game.ReplicatedStorage.RemoteEvents.ValueChanger:FireServer()
wait(0.5)
game.ReplicatedStorage.RemoteEvents.BestTimeRemote:FireServer()
end
end)
game.StarterGui.side.mainframe["to spawn"].MouseButton1Click:Connect(function(buttonClicked)
Active = false
game.Players.LocalPlayer.PlayerGui.TimerScreenGui.TimerFrame.TimerTextLabel.Text = ""
end)
DiePart.Touched:Connect(function(diePartTouched)
if diePartTouched.Parent.Name == game.Players.LocalPlayer.Name then
Active = false
game.Players.LocalPlayer.PlayerGui.TimerScreenGui.TimerFrame.TimerTextLabel.Text = "Died, RIP."
wait(1)
game.Players.LocalPlayer.PlayerGui.TimerScreenGui.TimerFrame.TimerTextLabel.Text = ""
end
end)
And the Server scripts:
game:WaitForChild("ReplicatedStorage"):WaitForChild("RemoteEvents"):WaitForChild("BestTimeRemote")
local times = {}
function getTimes()
for i ,v in pairs(game.Players:GetPlayers()) do
if v.Character:WaitForChild("TimeValue").Value == 0 then
print(""..v.Name.." did not Finish the Parkour yet!")
else
table.insert(times, ""..v.Name..": "..v.Character:WaitForChild("TimeValue").Value)
end
end
return times
end
pcall(getTimes)
if table[1] == nil then
script.Parent.Text = "Nobody Finish the Parkour yet!"
else
script.Parent.Text = ""..times[1]
end
game.ReplicatedStorage.RemoteEvents.BestTimeRemote.OnServerEvent:Connect(function(player)
wait(0.2)
pcall(getTimes)
wait()
table.sort(times)
wait(0.1)
if table[1] == nil then
script.Parent.Text = "Nobody Finish the Parkour yet!"
else
script.Parent.Text = ""..times[1]
end
end)
game.ReplicatedStorage.RemoteEvents.ValueChanger.OnServerEvent:Connect(function(player)
player.Character:WaitForChild("TimeValue")
player.Character.TimeValue.Value = script.Parent.Text
end)
game.Players.PlayerAdded:Connect(function(playerJoined)
playerJoined.CharacterAdded:Connect(function(characterAdded)
local NumberValue = Instance.new("NumberValue", characterAdded)
NumberValue.Name = "TimeValue"
end)
end)
Thank you for taking ur time reading this!

3 comments
Do you get an error?
No, it does nothing at all.
I added a print and it worked. I tried putting the print in the last line and it worked too