so basically this local script under starterplayerscripts is suppose to make the player run when they press leftcontrol but for some reason its not working and i cant seem to find out why?
local players = game:GetService("Players")
local locpl = players.LocalPlayer
local UserInputServer = game:GetService("UserInputService")
local humanoid = locpl.Character.Humanoid
local Ranimation = game.StarterPlayer.StarterCharacterScripts.RUN.RunAnim
local playit = humanoid:LoadAnimation(Ranimation)
UserInputServer.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl and locpl.Character:FindFirstChild("Humanoid") then
print("leftctrl pressed")
locpl.Character.Humanoid.WalkSpeed = 30
playit:Play()
end
end)
UserInputServer.InputEnded:Connect(function(input)
locpl.Character:FindFirstChild("Humanoid").WalkSpeed = 16
playit:Stop()
end)
This might not be the cause of your problem, but please check what input has ended after InputEnded fires. If the input is not checked, any input, even WASD, that ends will automatically make the walkspeed go to 16 and cause the animation to stop playing.
local players = game:GetService("Players")
local locpl = players.LocalPlayer
local UserInputServer = game:GetService("UserInputService")
UserInputServer.InputBegan:Connect(function(input)
if locpl.Character and input.KeyCode == Enum.KeyCode.LeftControl and locpl.Character:FindFirstChildWhichIsA("Humanoid") then
print("leftctrl pressed")
locpl.Character:FindFirstChildWhichIsA("Humanoid").WalkSpeed = 30
--playit:Play()
end
end)
UserInputServer.InputEnded:Connect(function(input)
if locpl.Character and input.KeyCode == Enum.KeyCode.LeftControl and locpl.Character:FindFirstChildWhichIsA('Humanoid') then
locpl.Character:FindFirstChild("Humanoid").WalkSpeed = 16
end
--playit:Stop()
end)
works fine for me, placed it in starterplayerscripts
its either
a. something i dont know and im stupid and AAAA
b. you didnt check which input on InputEnded this is the most likely one
c. local humanoid = locpl.Character.Humanoid you tried localizing something that might not exist unless you put it in startercharacterscripts which would be stupid
d. the animation erroring? doubt it but maybe
e. some server script
There are a few things that could be causing this issue. Here are a few things you can try:
Make sure that the RUN module is correctly spelled and that it exists in the StarterCharacterScripts folder.
Make sure that the RunAnim object exists in the RUN module and that it is an Animation object.
Make sure that the locpl.Character.Humanoid object exists and is a valid Humanoid object.
Make sure that the UserInputService is correctly spelled and that it is a valid service.
Make sure that the InputBegan and InputEnded events are being fired by the UserInputService . You can test this by adding a print statement inside each of the event handlers (e.g. print("InputBegan fired") ).
Make sure that the playit:Play() and playit:Stop() functions are being called at the appropriate times. You can test this by adding a print statement before and after each of these calls (e.g. print("Starting animation") , print("Stopping animation") ).
I hope this helps! Let me know if you have any other questions.
I’m sorry to hear that the issue is still not resolved. Here are a few more things you can try:
Make sure that the character model is properly rigged and that the Humanoid object has the correct animation track assigned to it.
Check the Humanoid’s Health property to make sure it is greater than 0. If the Humanoid’s Health is 0 or less, the character will not be able to play animations.
Make sure that the RUN module is properly configured and that it is not conflicting with any other code in your project.
Try using the :FindFirstChild() method to verify that the necessary objects and services are present in the game. For example.
local runModule = script.Parent:FindFirstChild("RUN")
if not runModule then
print("RUN module not found")
end
Check the Output window for any error messages that may indicate the source of the issue.
I hope these suggestions help! If you’re still having trouble, it might be helpful to share your code with me so I can take a closer look.