#My Weapon Doesn't Work

1 messages · Page 1 of 1 (latest)

formal sail
#

I'm making a script for a dagger weapon, but for some reason it's not doing anything and has no errors in the output.

stone umbra
#

Ok

formal sail
#
local equipped = false
local abilityevent = game.ReplicatedStorage.AbilityEvent
local uis = game.UserInputService

tool.Equipped:Connect(function()
    equipped = true
end)

tool.Unequipped:Connect(function()
    equipped = false
end)

uis.InputBegan:Connect(function(inp, proc)
    if not equipped then return end
    if proc then return end
    local mouse = game.Players.LocalPlayer:GetMouse()
    if inp.KeyCode == Enum.KeyCode.Z then
        abilityevent:FireServer("Z", mouse.Hit.Position)
    elseif inp.KeyCode == Enum.KeyCode.X then
        abilityevent:FireServer("X", mouse.Hit.Position)
    end
end)```
#
local deb = false


local function Z(HumanoidRootPart, Damage, Humanoid, TweenLength)
    local emmiter = script.Smoke:Clone()
    emmiter.Parent = HumanoidRootPart
    local ts = game:GetService("TweenService")
    local ti = TweenInfo.new(TweenLength, Enum.EasingStyle.Back)
    local model = game.ServerStorage.DaggerAttack:Clone()
    model.Parent = workspace
    model:PivotTo(HumanoidRootPart.CFrame)
    HumanoidRootPart.Anchored = true
    for i, v in model:GetChildren() do
        local tween = ts:Create(
            v.Handle,
            ti,
            {CFrame = HumanoidRootPart.CFrame}
        )
        tween:Play()
    end
    task.wait(TweenLength)
    emmiter:Emit(1)
    Humanoid.Health -= Damage
end

event.OnServerEvent:Connect(function(player, ability, mousepos)
    if deb then return end
    deb = true
    task.delay(1, function()
        deb = false
    end)
    local humanoidrootpart:BasePart = player.Character.HumanoidRootPart
    local direction = (mousepos - humanoidrootpart.Position).Unit * 1000
    local params = RaycastParams.new()
    params.FilterDescendantsInstances = {player.Character}
    params.FilterType = Enum.RaycastFilterType.Exclude
    local raycastresult = workspace:Raycast(humanoidrootpart.Position, direction, params)
    
    if raycastresult.Instance.Parent:FindFirstChild("Humanoid") then
        local humanoid = raycastresult.Instance.Parent.Humanoid
        local humanoidrootpart = raycastresult.Instance.Parent.HumanoidRootPart
        Z(humanoidrootpart, 25, humanoid, 0.5)
    end
end)```
stone umbra
#

Before I go through and read all this, does your tool have a handle? And if not, do you have the requires handle property off? @formal sail

formal sail
#

o