Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I can't solve the problem because I don't know what the problem here is?

Asked by 5 years ago

Hello, my code doesn't execute I think I forgot something here with filtering enabled I think. I'm very unsure about the problem so thats why I can't solve it myself..

Anyone else who does?

local ContextActionService = game:GetService("ContextActionService")

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

-- Add a debounce variable
local debounce = false

local function pressedXHandler()
    if debounce then return end
debounce = true
    local hitCharacter = mouse.Target.Parent
    local hitHumanoid = hitCharacter:FindFirstChildWhichIsA("Humanoid")
    if hitHumanoid then

        hitHumanoid:TakeDamage(25)
hitCharacter.Humanoid.Sit = true
local Push = Instance.new("BodyVelocity", hitCharacter.Torso)
Push.Velocity = hitCharacter.Torso.CFrame.lookVector * -63
Push.MaxForce = Vector3.new(math.huge, math.huge, math.huge)

local Distance = Instance.new("BodyPosition", hitCharacter.Torso)
Distance.MaxForce = Vector3.new(0, 0, 2)
Distance.Position = Vector3.new(0, hitCharacter.CFrame.p.Y + 15, 0)

Push:Destroy()
Distance:Destroy()


        wait(5)
        hitCharacter.Humanoid.Sit = false
end 
    wait(20) -- This is the cooldown time
    debounce = false
end

ContextActionService:BindAction("nameOfAction", pressedXHandler, false, Enum.KeyCode.X)

Thanks tho

0
What do you mean your code "doesn't execute", does it not work at all? Does it stop working at a specific line. This is general debugging and should be included in your question. SummerEquinox 643 — 5y
1
Not going to be able to damage other players or move them via a localscript, will need to do via remote event Vulkarin 581 — 5y
0
Ohh thats the problem 3dwardIsBack -10 — 5y

Answer this question