Hello! I’m making a script for handling acrobatic tricks. My current goal is to have the character move a tiny bit with each trick if they’re stationary using a Vector3. However, nothing’s happening in terms of player movement if I run the script. Can anyone help? Thanks.
local RS = game:GetService("ReplicatedStorage")
local CAS = game:GetService("ContextActionService")
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local Animations = RS.Assets.Animations
local Tricks = {
["Compasso"] = {["Keybind"] = Enum.KeyCode.R};
["Cartwheel"] = {["Keybind"] = Enum.KeyCode.F};
["HookKick"] = {["Keybind"] = Enum.KeyCode.V};
}
for _, Animation in Animations:GetChildren() do
local FoundAnimation = Tricks[Animation.Name]
Tricks[Animation.Name] = {
["Keybind"] = FoundAnimation and FoundAnimation.Keybind or false,
["Animation"] = Animator:LoadAnimation(Animation)
}
end
local function doGroundTrick(TrickName, State)
if State ~= Enum.UserInputState.Begin then return end
local Trick = Tricks[TrickName]
assert(Trick.Animation, TrickName .. " has no animation") -- Check if the trick has an animation
Trick.Animation:Play()
end
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.R or input.KeyCode == Enum.KeyCode.F or input.KeyCode == Enum.KeyCode.V then
Player.Character.Humanoid:Move(Vector3.new(0,0,5), true) -- The problem script
end
end)
for Trick, Info in Tricks do
if not Info.Keybind then continue end
CAS:BindAction(Trick, doGroundTrick, true, Info.Keybind)
end