So, I am working on a speed simulator-type game, where a player’s speed is determined based on a value,
How can I update the player’s speed in real-time as they click?
I am willing to provide any script or resource that you might need to help answer this question
I believe you can do both of these at the same time. In pseudocode, it would be like this:
mouse clicked
change number value object or variable by some amount
walkspeed += that number/variable * some ratio to compensate (you don't need this if you want the value to be one to one)
How would I implement that into my current “Click Script”?
local player = game.Players.LocalPlayer
local Speed = player:WaitForChild("leaderstats"):WaitForChild("Speed")
local sound = script["Pop Sound!"]
debounce = true
game:GetService("UserInputService").InputBegan:Connect(function(input, engine_processed)
if engine_processed then
return
end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if debounce == true then
debounce = false
Speed.Value = Speed.Value +1
sound:Play()
wait(0.15)
debounce = true
end
end
end)
ok so what you want to do is whenever the value changes add to the walkspeed this script would work I think but you would need to change the Values and stuff depending on how much they get per click
game.Players.PlayerAdded:Connect(function(player)
-- add in all your leaderstats
[Value containing your Speed/Clicks].Changed:Connect(function()
local Char = player.Character or player.CharacterAdded:Wait() -- I think that is how it works but unsure on the second bit
if not Char then return end
local Hum = Char.Humanoid
if not Hum then return end
Hum.WalkSpeed = ([Value containing your Speed/Clicks].Value/[put i value here but it will be alot of trial and error to get the best result]) + 16
end)
end)
I don’t think you truly need a separate value. Couldn’t you just use a script that changes Humanoid.Walkspeed?
I don’t even think a separate value is needed for data-saving.