tryna make a crouch input began thingy and it wont work
local UserInputService = game:GetService("UserInputService")
local plr = game:GetService("Players").LocalPlayer
local character = plr.CharacterAdded:Wait()
local humanoid = character.Humanoid
local speed = 10
local id = "rbxassetid://13377282143"
local animation = humanoid:LoadAnimation(id)
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
print("hi")
character = true
character.Humanoid.WalkSpeed = speed
animation:Play()
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
print("hii")
character = false
character.Humanoid.WalkSpeed = 16
animation:Stop()
end
end)```
oh shoot wait, i made two variables the same. whoops, but character is just supposed to be a boolean value i added in a starter character. Ill go fix it and see if anything changes
now im just realizing i didnt even add the character boolean thingy variable
local plr = game:GetService("Players").LocalPlayer
local character = plr.CharacterAdded:Wait()
local humanoid = character.Humanoid
local crouch = character.Variables.Crouched
local speed = 10
local crouchAnimation = Instance.new("Animation")
crouchAnimation.AnimationId = "rbxassetid://13377282143"
local animation = humanoid:LoadAnimation(crouchAnimation)
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
print("hi")
crouch = true
character.Humanoid.WalkSpeed = speed
animation:Play()
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
print("hii")
crouch = false
character.Humanoid.WalkSpeed = 16
animation:Stop()
end
end)```
local UserInputService = game:GetService("UserInputService")
local plr = game:GetService("Players").LocalPlayer
local character = plr.CharacterAdded:Wait()
local charbool
local humanoid = character.Humanoid
local speed = 10
local id = "rbxassetid://13377282143"
local animationInstance = Instance.new("Animation")
animationInstance.AnimationId = id
local animation = humanoid:LoadAnimation(animationInstance)
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
print("hi")
charbool = true
character.Humanoid.WalkSpeed = speed
animation:Play()
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
print("hii")
charbool = false
character.Humanoid.WalkSpeed = 16
animation:Stop()
end
end)
Is this server Script or LocalScript?
If it’s a LocalScript, I would check to make sure it is parented to a place in which the script can execute, such as StarterCharacterScripts, StarterPlayerScripts, etc.