#The sprinting script wont work in my game!
1 messages · Page 1 of 1 (latest)
oh my bad wait
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local walkSpeed = 16
local sprintSpeed = 20
player.CharacterAdded:Connect(function(char)
character = char
humanoid = character:WaitForChild("Humanoid")
end)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.LeftShift and not gameProcessed then
if humanoid then
humanoid.WalkSpeed = sprintSpeed
end
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
if humanoid then
humanoid.WalkSpeed = walkSpeed
end
end
end)
RunService.RenderStepped:Connect(function()
if UserInputService.TouchEnabled then
if humanoid and humanoid.MoveDirection.Magnitude > 0 then
humanoid.WalkSpeed = sprintSpeed
else
humanoid.WalkSpeed = walkSpeed
end
end
end)
i put that in starter player scripts
local script
didnt work
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local walkSpeed = 16
local sprintSpeed = 20
player.CharacterAdded:Connect(function(char)
character = char
humanoid = character:WaitForChild("Humanoid")
end)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.LeftShift and not gameProcessed then
if humanoid then
humanoid.WalkSpeed = sprintSpeed
end
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
if humanoid then
humanoid.WalkSpeed = walkSpeed
end
end
end)
RunService.RenderStepped:Connect(function()
if UserInputService.TouchEnabled then
if humanoid and humanoid.MoveDirection.Magnitude > 0 then
humanoid.WalkSpeed = sprintSpeed
else
humanoid.WalkSpeed = walkSpeed
end
end
end)
seems to be working just fine. But you do have a rather low difference between sprinting and walking, so it is almost not noticeable
yea as my map is quite long so
we need players to sprint fast!
Well then... actually increase the difference
16 -> 20 is a barely noticeable increase
you know the error as its not working at all in my game
oh crap
thats why it didnt got noticed
gosh dang it am such an idiot
is my script a fully working script or does it have some errors
Well the renderstepped function seems a bit off, as it doesn't really do anything currently
so whats the corrected script?
I mean, you can just remove that last function
But the rest of the script is working just fine
is this the script?
** You are now Level 1! **
That's your script just posted in a codeblock
CAN u send in the script with you removing the last function i have 0 programming skills
how do i do that
the run service?
do i delete that
Please learn the absolute basics of using a computer...
my bad
Just remove that last function, then change the number after sprintSpeed
just did that it didnt work
They should add a mandatory IQ test for folks wishing to access the internet
what?
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local walkSpeed = 16
local sprintSpeed = 20 -- increase this number to your liking
player.CharacterAdded:Connect(function(char)
character = char
humanoid = character:WaitForChild("Humanoid")
end)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.LeftShift and not gameProcessed then
if humanoid then
humanoid.WalkSpeed = sprintSpeed
end
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
if humanoid then
humanoid.WalkSpeed = walkSpeed
end
end
end)
yes i removed thge last function
this is the result local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local walkSpeed = 16
local sprintSpeed = 30
player.CharacterAdded:Connect(function(char)
character = char
humanoid = character:WaitForChild("Humanoid")
end)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.LeftShift and not gameProcessed then
if humanoid then
humanoid.WalkSpeed = sprintSpeed
end
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
if humanoid then
humanoid.WalkSpeed = walkSpeed
end
end
end)
but it yet did not wor
... Is it a local script?
yes
What is the script's parent?
in starter player scripts
wait how did you write this if you have 0 programming skills
chatgpt
starter player scripts
am doing it in test play
yes
And you are noticing the mild speed increase, right?
Nope.
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local walkSpeed = 16
local sprintSpeed = 300
player.CharacterAdded:Connect(function(char)
character = char
humanoid = character:WaitForChild("Humanoid")
end)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.LeftShift and not gameProcessed then
if humanoid then
humanoid.WalkSpeed = sprintSpeed
end
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
if humanoid then
humanoid.WalkSpeed = walkSpeed
end
end
end)
if UserInputService.TouchEnabled then
humanoid.WalkSpeed = sprintSpeed
end
use this
Then tell me if you can notice it
Bottom was just quickly added for those mobile players
didnt work
Press ctrl + shift + F. Then in the window that opens up type "Walkspeed", then tell me how many results that is showing
as seen in this image
in which parent
In the window that opens up after pressing down those 3 buttons
i did it
** You are now Level 2! **
it shows many stuff
So you've 10 scripts all trying to change the walkspeed
this is why you don't use AI for coding
Welp, have fun fixing it
Eh fuck it, let me explain it in simple terms.
Say 5 people are sitting in a room, all wanting the room to be a different temperature. Everybody is messing with the thermostat and causing the room to constantly change temperatures, what you just did is add another person onto that pile and asked him to set the temperature to 35 C, and now you're confused that it's not reaching 35 C, as somebody else keeps changing it back.
Now your AI scripts are doing the same
This is why you learn how to code
So have fun fixing that with chatgpt or whatever, as I highly doubt that anybody is going to helop you fix that mess
so your saying i should remove that script
i am using admin systems
those have nothing to do with sprints
using Lshift
Yet they still try to change your walkspeed back
This is why you learn how to script, instead of just pasting in modules, ai code, etc. then complain that shit isn't working
shit