I am writing a speedrun system for my game and I need this script to be functional for the remote event to fire and change a intvalue in the player it is supposed to continuously wait non stop until the speedrun boolvalue is enabled to run, but it does not run at all.
local value = game.Players.LocalPlayer.speedrun.Value
while not value do
wait()
end
while value do
if value == true then
game.ReplicatedStorage.speedrunaddcount:FireServer(game.Players.LocalPlayer)
else
return
end
end
Script responsible for assigning the name in correlation to the value of the intvalue
while true do
wait()
script.Parent.Text = game.Players.LocalPlayer.speedruncounter.Value
end
Server script that handles the remote (I already have a extremely powerful anticheat in place)
You should be adding the value on the server, or exploiters can just set their time to whatever they want or remove counting altogether. It would also be easier to program for you.
If you could show me the server code, I can implement it for you.
doing while value do could be interpreted by the compiler as while value == true do
try this script and lmk if it works
local value = game.Players.LocalPlayer:WaitForChild("speedrun")
while value ~= nil do
if value.Value == true then
game.ReplicatedStorage.speedrunaddcount:FireServer(game.Players.LocalPlayer)
else
return
end
end
I am aware of this fact, I have been programming for more than 5 years now, it is a simple (OPTIONAL) mode of the game that resets your stage to zero, disables datastore so you don’t lose your regular stage, waits for you to finish then saves it and puts it on the learderboard.
game:GetService("Players").PlayerAdded:Connect(function(player)
local speedrun = player:WaitForChild("speedrun")
speedrun.Changed:Connect(function()
while task.wait(0.1) and speedrun.Value do
player.speedruncounter.Value += 0.01
end
end)
end)
For a FireServer event, it automatically has a Player variable.
local value = game.Players.LocalPlayer.speedrun.Value
while not value do
wait()
end
while value do
if value == true then
game.ReplicatedStorage.speedrunaddcount:FireServer()
else
return
end
end
Script responsible for assigning the name in correlation to the value of the intvalue
while true do
wait()
script.Parent.Text = game.Players.LocalPlayer.speedruncounter.Value
end
Server script that handles the remote (I already have a extremely powerful anticheat in place)
A.K.A. If you use :FireServer() from client, it automatically puts the player as the first option. OnServerEvent(Player)
SO if you do FireServer(player) it messes with the code, and it doesn’t work.
Could you tell me what this prints when the speedrun value changes?
game:GetService("Players").PlayerAdded:Connect(function(player)
local speedrun = player:WaitForChild("speedrun")
speedrun.Changed:Connect(function()
print(speedrun.Value)
while task.wait(0.1) and speedrun.Value do
player.speedruncounter.Value += 0.01
end
end)
end)
I even tried re tethering it to a remote and firing it with a simple while true do script but even that failed to work. I am just going to have to find another method to store time. or unless intvalues have some hidden property that continuiously sets any integer below 1 to 0.
I put two and two together and realized that integer values can only store integers, an integer is literally a whole number, I don’t know why I didn’t realize this but here is the adjusted script for an integer value.
game:GetService("Players").PlayerAdded:Connect(function(player)
local speedrun = player:WaitForChild("speedrun")
local speedruncounter = player:WaitForChild("speedruncounter")
speedrun.Changed:Connect(function()
while wait(0.1) and speedrun.Value do
local currentCounter = tonumber(speedruncounter.Value) or 0
speedruncounter.Value = tostring(currentCounter + 0.01)
end
end)
end)