Basically im trying to do a Best Time script. But the Value that is in everybodys Character wont Change. Here are the Scripts:

Value Giver & Changer

game.Players.PlayerAdded:Connect(function(playerJoined)
	playerJoined.CharacterAdded:Connect(function(characterAdded)
		local NumberValue = Instance.new("NumberValue", characterAdded)
		NumberValue.Name = "TimeValue"
	end)
end)

game.ReplicatedStorage.RemoteEvents.ValueChanger.OnServerEvent:Connect(function(plr)
	plr.Character.TimeValue.Value = plr.PlayerGui.timer.time.Text
end)

Time Changer

local times = {}
local Players = game.Players

function getPlayerTimes()
	for i, v in pairs(Players:GetPlayers()) do
		if v.Charater.TimeValue.Value ~= 0 then
			table.insert(times, v.Character.TimeValue.Value)
		end
	end
	return times
end

function loadlTimes()
	if times[1] == nil then
		script.Parent.eins.Text = "Nobody"
		script.Parent.zwei.Text = "Nobody"
		script.Parent.drei.Text = "Nobody"
		script.Parent.vier.Text = "Nobody"
		script.Parent.fuenf.Text = "Nobody"
	else
		table.sort(times)
		wait(0.5)
		if times[1] then
			script.Parent.eins.Text = times[1]
		end
		if times[2] then
			script.Parent.zwei.Text = times[2]
		end
		if times[3] then
			script.Parent.drei.Text = times[3]
		end
		if times[4] then
			script.Parent.vier.Text = times[4]
		end
		if times[5] then
			script.Parent.fuenf.Text = times[5]
		end
	end
end

pcall(getPlayerTimes)
pcall(loadlTimes)

game.ReplicatedStorage.RemoteEvents.BestTimeRemote.OnServerEvent:Connect(function(player)
	pcall(getPlayerTimes)
	pcall(loadlTimes)
end)

Player Time Changer

local times = {}
local Players = game.Players

function getPlayerTimes()
	for i, v in pairs(Players:GetPlayers()) do
		if v.Charater.TimeValue.Value ~= 0 then
			table.insert(times, v.Character.TimeValue.Value)
		end
	end
	return times
end

function loadPlayers()
	if times[1] == nil then
		script.Parent.eins.Text = "Nobody"
		script.Parent.zwei.Text = "Nobody"
		script.Parent.drei.Text = "Nobody"
		script.Parent.vier.Text = "Nobody"
		script.Parent.fuenf.Text = "Nobody"
	else
		table.sort(times)
		wait(0.5)
		for i, v in pairs(Players:GetPlayers()) do
			if times[1] then
				if v.Character.TimeValue.Value == times[1] then
					script.Parent.eins.Text = v.Character.Name
				end
			end
			if times[2] then
				if v.Character.TimeValue.Value == times[2] then
					script.Parent.zwei.Text = v.Character.Name
				end
			end
			if times[3] then
				if v.Character.TimeValue.Value == times[3] then
					script.Parent.drei.Text = v.Character.Name
				end
			end
			if times[4] then
				if v.Character.TimeValue.Value == times[4] then
					script.Parent.vier.Text = v.Charater.Name
				end
			end
			if times[5] then
				if v.Character.TimeValue.Value == times[5] then
					script.Parent.fuenf.Text = v.Character.Name
				end
			end
		end
	end
end

pcall(getPlayerTimes)
pcall(loadPlayers)

game.ReplicatedStorage.RemoteEvents.BestTimeRemote.OnServerEvent:Connect(function(player)
	pcall(getPlayerTimes)
	pcall(loadPlayers)
end)

3 comments

0

the two last scripts are basically the same thing btw. The second one is for the player name and the first is for the time

0

I tried but i dont know whats wrong, i barelly understood what is it trying to do :v Like, when does even the RemoteEvent is fired?