Hello, I’ve been trying to make an ability in my game and it didn’t work, I then copied some code from one of my other games and it still didn’t work for some reason (it works in the other game), so I would like to know why this isn’t working.
Here’s the code:
local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local rootpart = char:WaitForChild("HumanoidRootPart")
local rs = game:GetService("RunService")
local replicated = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")
local gameplayUI = plr.PlayerGui:WaitForChild("GameplayUI")
gameplayUI.Enabled = true
local rayIgnore = {char}
uis.InputBegan:Connect(function(i,g)
if g then return end
if i == Enum.KeyCode.C then
if hum:GetState() == Enum.HumanoidStateType.Freefall or hum:GetState() == Enum.HumanoidStateType.Jumping then
local ray = RaycastParams.new()
ray.FilterDescendantsInstances = rayIgnore
local hit = workspace:Raycast(rootpart.Position,(-rootpart.CFrame.LookVector*10),ray)
if hit then
print("found part")
rootpart.Velocity = (rootpart.CFrame.LookVector*57)
else
print("part not found")
end
end
end
end)