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

Ok so i want this script to work only when the slapper tool is equipped so what am I doing wrong?

Asked by 3 years ago
local Fireball = game.ServerStorage:WaitForChild("Fireball")

--Put tool they should have here
local tool = slapper

game.ReplicatedStorage.Fireball.OnServerEvent:Connect(function(player,cframe)

    local character = player.Character

   --Check if tool equipped, otherwise return/exit function
    if character:FindFirstChild(tool.Name) == nil then return end


    local newFireball = Fireball:Clone()
    newFireball.CFrame = character.HumanoidRootPart.CFrame

    local bodyVelocity = Instance.new("BodyVelocity")
    bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
    bodyVelocity.Velocity = (character.HumanoidRootPart.CFrame.lookVector*100)
    bodyVelocity.Parent = newFireball

    newFireball.Parent = workspace

    local touchConn

    touchConn = newFireball.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
            if hit.Parent.Name ~= player.Name then
                local humanoid = hit:FindFirstAncestorWhichIsA("Model").Humanoid
                humanoid:TakeDamage(25)

                if touchConn ~= nil then touchConn:Disconnect() end
                newFireball:Destroy()
            end
        end
    end)

    wait(2)

    if touchConn ~= nil then touchConn:Disconnect() end
    newFireball:Destroy()

end)
0
When I told you to "put the tool here," I didn't mean literally. You should index the tool from wherever it is stored. Perhaps consider learning the basics about game hierarchy first: https://www.youtube.com/watch?v=BfLUt3mfJiY Sparks 534 — 3y
0
Isn't Tool.Equipped an event? Zeuxulaz 148 — 3y

Answer this question