#sprint script not working as expected

106 messages · Page 1 of 1 (latest)

fringe phoenix
#

-- Services

local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
local players = game:GetService("Players")

-- Player Character

local player = players.LocalPlayer
local character = player.Character

local humanoid = character:WaitForChild("Humanoid")

-- attributes

local Base_Walkspeed = script:GetAttribute("Base_WalkSpeed")
local Sprint_Speed = script:GetAttribute("Sprint_Speed")

#

-- Function

UIS.InputBegan:Connect(function(key)
if key.UserInputType == Enum.UserInputType.Keyboard then
if key.KeyCode == Enum.KeyCode.LeftShift then
print("Sprint Activated")
-- FOV

        local FOVProperties = {FieldOfView = 90}
        local FOVTweenInfo = TweenInfo.new(0.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
        local FOVTween = TS:Create(workspace.CurrentCamera, TweenInfo, FOVProperties)
        FOVTween:Play()
        
        -- Sprint Tween
        
        local Properties = {WalkSpeed = Sprint_Speed}
        local Info = TweenInfo.new(0.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
        local Tween = TS:Create(humanoid, Info, Properties)
        Tween:Play()
    end
end

end)

UIS.InputEnded:Connect(function(key)
if key.UserInputType == Enum.UserInputType.Keyboard then
if key.KeyCode == Enum.KeyCode.LeftShift then
print("Sprint Deactivated")
-- FOV

        local FOVProperties = {FieldOfView = 70}
        local FOVTweenInfo = TweenInfo.new(0.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
        local FOVTween = TS:Create(workspace.CurrentCamera, FOVTweenInfo, FOVProperties)
        FOVTween:Play()

        -- Sprint Tween

        local Properties = {WalkSpeed = Base_Walkspeed}
        local Info = TweenInfo.new(0.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
        local Tween = TS:Create(humanoid, Info, Properties)
        Tween:Play()
    end
end

end)

#

its supposed to have an increasing acceleration

#

nvm

grim geyser
#

rememrb to check for game proccssed

fringe phoenix
#

issue resolved

grim geyser
#

and idk why you have UserInputType.Keyboard

fringe phoenix
#

Game proccessed?

grim geyser
#

yea

#

for UIS

#

so that if a player types in chat and they click that key

#

it wont register

fringe phoenix
#

oh ok, how would i do that

grim geyser
#

``lua

#

oops

#
UIS:InputBegan:Connect(function(key, processed)
if processed then return end
#

js put that at the top

fringe phoenix
#

like very top

#

do i not need to end it

#

with end

grim geyser
#

ye

#

and its UIS.InputBegan

#

sorry

#

not :

fringe phoenix
#

my movespeed isnt changing for some reason

grim geyser
#

?

#

was it changing before

fringe phoenix
#

no

#

i only just noticed it is all

#

fov change made me believe it odes

#

but like

#

my attributes at 480

#

''''lua
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local Base_Walkspeed = script:GetAttribute("Base_WalkSpeed")
local Sprint_Speed = script:GetAttribute("Sprint_Speed")

UIS.InputBegan:Connect(function(key, processed)
if processed then return end
end)

UIS.InputBegan:Connect(function(key)
if key.UserInputType == Enum.UserInputType.Keyboard then
if key.KeyCode == Enum.KeyCode.LeftShift then
print("Sprint Activated")
local FOVProperties = {FieldOfView = 90}
local FOVTweenInfo = TweenInfo.new(0.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local FOVTween = TS:Create(workspace.CurrentCamera, FOVTweenInfo, FOVProperties)
FOVTween:Play()

        local Properties = {WalkSpeed = Sprint_Speed}
        local Info = TweenInfo.new(0.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
        local Tween = TS:Create(humanoid, Info, Properties)
        Tween:Play()
    end
end

end)

UIS.InputEnded:Connect(function(key)
if key.UserInputType == Enum.UserInputType.Keyboard then
if key.KeyCode == Enum.KeyCode.LeftShift then
print("Sprint Deactivated")
local FOVProperties = {FieldOfView = 70}
local FOVTweenInfo = TweenInfo.new(0.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local FOVTween = TS:Create(workspace.CurrentCamera, FOVTweenInfo, FOVProperties)
FOVTween:Play()

        local Properties = {WalkSpeed = Base_Walkspeed}
        local Info = TweenInfo.new(0.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
        local Tween = TS:Create(humanoid, Info, Properties)
        Tween:Play()
    end
end

end)

grim geyser
#

for mat it

#

format*

fringe phoenix
#

how

#

?

grim geyser
#

use `

#

x3 of `

#

then type lua

#

not quotations

#

and then at the end of your script put ` x3

fringe phoenix
#
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local Base_Walkspeed = script:GetAttribute("Base_WalkSpeed")
local Sprint_Speed = script:GetAttribute("Sprint_Speed")

UIS.InputBegan:Connect(function(key, processed)
    if processed then return end
end)

UIS.InputBegan:Connect(function(key)
    if key.UserInputType == Enum.UserInputType.Keyboard then
        if key.KeyCode == Enum.KeyCode.LeftShift then
            print("Sprint Activated")
            local FOVProperties = {FieldOfView = 90}
            local FOVTweenInfo = TweenInfo.new(0.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
            local FOVTween = TS:Create(workspace.CurrentCamera, FOVTweenInfo, FOVProperties)
            FOVTween:Play()

            local Properties = {WalkSpeed = Sprint_Speed}
            local Info = TweenInfo.new(0.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
            local Tween = TS:Create(humanoid, Info, Properties)
            Tween:Play()
        end
    end
end)

UIS.InputEnded:Connect(function(key)
    if key.UserInputType == Enum.UserInputType.Keyboard then
        if key.KeyCode == Enum.KeyCode.LeftShift then
            print("Sprint Deactivated")
            local FOVProperties = {FieldOfView = 70} 
            local FOVTweenInfo = TweenInfo.new(0.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
            local FOVTween = TS:Create(workspace.CurrentCamera, FOVTweenInfo, FOVProperties)
            FOVTween:Play()

            local Properties = {WalkSpeed = Base_Walkspeed}
            local Info = TweenInfo.new(0.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
            local Tween = TS:Create(humanoid, Info, Properties)
            Tween:Play()
        end
    end
end)
#

sorry

grim geyser
#

why do you tween the walk speed

fringe phoenix
#

idk

#

Im mostly following along with a tutorial

#

trying to understand it

#

to some degree

#

and this dude didnt use tts

grim geyser
#

hmm

#

no console errors?

fringe phoenix
#

1 related one

#

TweenService:Create property named 'WalkSpeed' cannot be tweened due to type mismatch (property is a 'float', but given type is 'string')

#

can i just do the python float(walkspeed)

grim geyser
#

hm

#

change the attribute type to a float

fringe phoenix
#

ok

grim geyser
#

like when you make an attribute you can choose which type it is

#

so js change to float and it should work

#

both of them

fringe phoenix
#

float is just number right

grim geyser
#

ye

fringe phoenix
#

that fixed it

karmic reefBOT
#

studio** You are now Level 16! **studio

fringe phoenix
#

thankyou brother

grim geyser
#

no problem

fringe phoenix
#

now to figure out how to play my run animation

grim geyser
#

still using the tutorial?

fringe phoenix
#

tutorial doesnt go that far

#

just goes to script

#

its just like doing
local anim = animation:getid('')
anim.play()

#

right

#

local anim is different obv

grim geyser
#

no

#
local animation = humanoid.Animator:LoadAnimation(script.Animation)
animation:Play()
fringe phoenix
#

which is nice

grim geyser
#

this is much more reliable

#

nice

fringe phoenix
#

roughly

grim geyser
#

oh

#

so you have the animation parented to the script?

fringe phoenix
#

going too

#

just need to import from blender

grim geyser
#

k

fringe phoenix
#

not great but itll do

#

atleast for prototyping

grim geyser
#

no that looks good

fringe phoenix
#

and then i get the fun of directional based movement

#

which is going to make me cry

grim geyser
#

yea

#

i think theres a tutorial ont hat somewhere

fringe phoenix
#

especially since my script already barely works

grim geyser
#

i remmebr seeing one i think

fringe phoenix
#

i make small things on random projects to test it out

#

then on this one im making them together

grim geyser
#

oh

fringe phoenix
#

but hopefully with better scripts

#

so ive gotten sprint to work before