--local script in Starterplayerscripts
local uis = game:GetService("UserInputService")
local PlrSer = game:GetService("Players")
local NS = 16
local FS = 200
local kcode = Enum.KeyCode
local UIT = Enum.UserInputType
local Plr = PlrSer.LocalPlayer
local ch = Plr.Character or Plr.CharacterAdded:Wait()
local function plrinput(key,B)
if not B then
if key.UserInputType == UIT.Keyboard then
if key.KeyCode == kcode.LeftShift then
ch.Humanoid.WalkSpeed = FS
--print("inp")
elseif key.KeyCode == kcode.R then
ch.Humanoid.Health = 0
end
elseif key.UserInputType == UIT.Gamepad1 then
if key.KeyCode == kcode.ButtonL2 then
ch.Humanoid.WalkSpeed = FS
end
end
end
end
uis.InputBegan:Connect(plrinput)
local function plrinputend(key,B)
if not B then
if key.UserInputType == UIT.Keyboard then
if key.KeyCode == kcode.LeftShift then
ch.Humanoid.WalkSpeed = NS
--print("inpend")
end
elseif key.UserInputType == UIT.Gamepad1 then
if key.KeyCode == kcode.ButtonL2 then
ch.Humanoid.WalkSpeed = NS
end
end
end
end
uis.InputEnded:Connect(plrinputend)
--the script worked when played once without dying, if i died and respawn it just doesnt work
Any help?
I tested the script on roblox studio and I can respawn, it may be another script.
Oh, I get it.
The fixed code
local uis = game:GetService(“UserInputService”)
local PlrSer = game:GetService(“Players”)
local NS = 16
local FS = 200
local kcode = Enum.KeyCode
local UIT = Enum.UserInputType
local Plr = PlrSer.LocalPlayer
Plr.CharacterAdded:Connect(function(ch)
local function plrinput(key,B)
if not B then
if key.UserInputType == UIT.Keyboard then
if key.KeyCode == kcode.LeftShift then
ch.Humanoid.WalkSpeed = FS
–print(“inp”)
elseif key.KeyCode == kcode.R then
ch.Humanoid.Health = 0
end
elseif key.UserInputType == UIT.Gamepad1 then
if key.KeyCode == kcode.ButtonL2 then
ch.Humanoid.WalkSpeed = FS
end
end
end
end
uis.InputBegan:Connect(plrinput)
local function plrinputend(key,B)
if not B then
if key.UserInputType == UIT.Keyboard then
if key.KeyCode == kcode.LeftShift then
ch.Humanoid.WalkSpeed = NS
–print(“inpend”)
end
elseif key.UserInputType == UIT.Gamepad1 then
if key.KeyCode == kcode.ButtonL2 then
ch.Humanoid.WalkSpeed = NS
end
end
end
end
uis.InputEnded:Connect(plrinputend)
end)
I used Plr.CharacterAdded
1 Like
i thought i made sure that character exists? hm
when the player is reset it doesn’t re-read the code im pretty sure idk
1 Like
Thank you, it works now i thought adding wait should yield the code but nah 