Hey guys. I’m back again for something of the same purpose. So I’ve recognised that I’m just not that great at scripting yet and I still need support on a speed simulator type game. (More like just the script.) I need some help with a script that adds 1 speed every second. I’ve already previously tried this and made a couple topics for help on the script but nothing seems to be working. So I came here Again to ask How would yous make a script that would add 1 speed every second I move in any direction?
See I’ve already looked over the developer forum for some help and still can’t find one. Anytime I search on YouTube for help it always comes up with exploits and how to inject something into the game. That’s not what I want. So I gave up with that soloution.
Any help is appreciated, Thanks!
Well this is not a place to ask for scripts but here is a example:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid")
while wait(1) do
Humanoid.WalkSpeed = Humanoid.WalkSpeed + 1
end
-- debug
print(Player.Name.."'s speed Is: "..Humanoid.WalkSpeed)
Don’t worry. I’m here because I need help. I simply can’t post a topic on anything else but Help and Feedback because of my low level rank. And seeing that I suck at scripting nothing you would say that’s complicated I would understand. How ever this makes sense because I can understand basic stuff.
I’m only here to ask for examples on how you’s would do it and what I’m missing and how I can improve my script from where it is already.
Local player = game.Players.LocalPlayer
local humanoidSpeed = player.Character.Humanoid.WalkSpeed
while true do
wait(1)
humanoidSpeed = humanoidSpeed + 1
end
When accessing services you should always use GetService because if the service you are trying to get doesn’t currently exist, GetService() will create it. For example, GetService("Players") will create the players service if it doesn’t currently exist.
local Players = game:GetService("Players") -- if not found, it will create the service when doing GetService().
local Player = Players.LocalPlayer -- the player.
local Character = Player.Character or Player.CharacterAdded:Wait() -- if not found, wait for it to be added.
local Humanoid = Character:WaitForChild("Humanoid") -- WaitForChild is mainly used on the client-side, as we cannot tell if the humanoid exists when this script is created.
while wait(1) do
Humanoid.WalkSpeed = Humanoid.WalkSpeed + 1
print(tostring(Player) .. "'s speed Is: " .. Humanoid.WalkSpeed)
end
-- Server-sided
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
local isRunning
if humanoid then
humanoid.Running:Connect(function(speed)
if speed > 0 then
isRunning = true
end
end)
end
end)
end)
Then you would use the boolean to control a specific loop of checking to add the humanoid’s walkspeed by 1 per second ran.
local player = game:GetService("Players")
local char = player.Character
while true do
wait(1)
char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed + 1
end
local character = game.Players.LocalPlayer.CharacterAdded:Wait()
local currentSpeed = 1 --Save speed
while wait(1) do --loop
currentSpeed += 1
character.Humanoid.WalkSpeed = currentSpeed
print("Current speed - "..currentSpeed)
end
I get the sense that you make a compelling case for what you actually want to accomplish. Unfortunately, you cannot ask others to write custom ground scripts for you in this category. You can use this category to draw the attention of other developers when you need assistance, such as when a scripting problem arises.
I think it’s that:
Put it on StarterCharacterScripts, as a LocalScript, put a ScreenGui in StarterGui, and put a TextLabel inside of the ScreenGui, to make the script to work perfectly fine.
game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid").WalkSpeed = 0
if game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid").WalkSpeed >= 0 then
game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text = "WalkSpeed: "..game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid").WalkSpeed
while task.wait(1) do
game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid").WalkSpeed = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid").WalkSpeed+1
game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text = "WalkSpeed: "..game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid").WalkSpeed
end
end