So I have a Wild West 1v1 game where currently you can run, walk, and jump and I’m trying to implement rolling when you press c whilst running. HOW???, I’m going to use your Roblox avatar and I’m not sure how to add an attachment on an avatar and then add a vector force, help.
Pls help me asap I’m very impatient and only one day till Monday
How I would go about this would be first animating a roll animation and then making the animation play when the key c is pressed.
Creating an Animation | Documentation - Roblox Creator Hub.
KeyCode | Documentation - Roblox Creator Hub
Yes but how do I add a vector force to a players avatar
If you want it serverside, then you would need to use a remote event and code the movement there.
no but how do i add a vector force to the avatar which hasn’t spawed yet
Currently it set up like this as a test but nothing happens the script is in starter character scripts if that helps
-- Services
local input = game:GetService("UserInputService")
local player = game:GetService("Players")
-- Variables
local player = player.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local humaniod = character:FindFirstChild("Humanoid")
-- Speeds
local walkSpeed = 14
local sprintSpeed = 28
local state = "walk"
local rolling = false
local rollDebounce = false
local rollTime = 1
-- Sprinting
input.InputBegan:Connect(function (key)
if key.KeyCode == Enum.KeyCode.LeftShift then
if humaniod then
character.Humanoid.WalkSpeed = sprintSpeed
state = "sprint"
end
end
end)
input.InputEnded:Connect(function (key)
if key.KeyCode == Enum.KeyCode.LeftShift then
if humaniod then
character.Humanoid.WalkSpeed = walkSpeed
state = "walk"
end
end
end)
-- Rolling
input.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.C and state == "sprint" and rollDebounce == false then
if humaniod then
print("roll")
rollDebounce = true
rolling = true
task.wait(rollTime)
rolling = false
rollDebounce = false
end
end
end)
-- Crouching
input.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.C and state == "walking" then
if humaniod then
local attachment = Instance.new("Attachment" , humaniod)
local force = Instance.new("VectorForce" , humaniod)
force.Attachment0 = attachment
force.Force = (Vector3.new(0,1,0)).Unit * 10000
force.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
end
end
end)
help me pls Im very impatient.