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

I'm making a bossfight but the swords don't damage the boss?

Asked by 4 years ago
Edited 4 years ago

Here is the bossfight script:

local TweenService = game:GetService("TweenService")

local monster = game.Workspace.monster

local function PlayMonsterAnimation()
    local animation = Instance.new("Animation", monster)
    animation.AnimationId = "http://www.roblox.com/asset/?id=507770677"

    local humanoid = monster:FindFirstChild("Humanoid")
    humanoid:LoadAnimation(animation):Play()

    wait(1)

    animation:Destroy()
end

local function fireballChallenge()

    for i=1, 3 do

        PlayMonsterAnimation()

        for i,player in pairs(game.Players:GetPlayers()) do
            if player.Character then
                local fireball = game.ReplicatedStorage.Fireball:Clone()
                local target = game.ReplicatedStorage.Target:Clone()

                target.Parent = game.Workspace
                target.CFrame = (player.Character.HumanoidRootPart.CFrame - Vector3.new(0,3,0)) * CFrame.Angles(0,0,math.rad(90))

                wait(0.5)

                fireball.Parent = game.Workspace
                fireball.CFrame = target.CFrame + Vector3.new(0,60,0)

                wait(2)

                target:Destroy()


            end
        end
        wait(1)

    end
end

local function lavaChallenge()

    local tweenInfo = TweenInfo.new(2)

    PlayMonsterAnimation()

    local goalPlatformUp = {}
    goalPlatformUp.CFrame = game.Workspace.Platforms.goalPositionPart.CFrame
    local movePlatformUpTween = TweenService:Create(game.Workspace.Platforms.Handle, tweenInfo, goalPlatformUp)

    movePlatformUpTween:Play()

    wait(2)

    local goalLavaUp = {}
    goalLavaUp.CFrame = game.Workspace.Lava.goalPositionPart.CFrame
    local moveLavaUpTween = TweenService:Create(game.Workspace.Lava.Handle, tweenInfo, goalLavaUp)

    moveLavaUpTween:Play()

    wait(7)

    local goalLavaDown = {}
    goalLavaDown.CFrame = game.Workspace.Lava.goalPositionPart.CFrame - Vector3.new(0,10,0)
    local moveLavaDownTween = TweenService:Create(game.Workspace.Lava.Handle, tweenInfo, goalLavaDown)

    moveLavaDownTween:Play()

    wait(3)

    local goalPlatformDown = {}
    goalPlatformDown.CFrame = game.Workspace.Platforms.goalPositionPart.CFrame - Vector3.new(0,10,0)
    local movePlatformDownTween = TweenService:Create(game.Workspace.Platforms.Handle, tweenInfo, goalPlatformDown)

    movePlatformDownTween:Play()

end

while wait(5) do

    if monster.Humanoid.Health > 0 then
    monster.ForceField.Visible = true

    lavaChallenge()
    fireballChallenge()

        monster.ForceField.Visible = false

    else
        break

    end


end

wait(1)

monster:Destroy()
game.Workspace.winDoor:Destroy()
print("The fight ended")

Also, I've made the sword have a local script for the damaging because I'm making it give you the sword. Here's the sword script:

local Sword = script.Parent

local function onTouch(partOther)

    local humanOther = partOther.Parent:FindFirstChild("Humanoid")

    if not humanOther then return end

    if humanOther.Parent == Sword then return end

    humanOther:TakeDamage(5)
end

local function slash()

    local str = Instance.new("StringValue")
    str.Name = "toolanim"
    str.Value = "Slash"
    str.Parent = Sword
end

Sword.Activated:Connect(slash)
Sword.Handle.Touched:Connect(onTouch)

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You used a localscript for the damage :/ dont do that, its only for the client and wont damage you properly, use a serverscript instead, when the slash animation plays, fire a RemoteEvent for the serverscript, then the damage will properly be done

0
It damages other players alright, but it still doesn't damage the boss.. What should I do? DriBowser 55 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Nevermind, I fixed it! All I had to do was make the boss's name a viewer type for some weird reason.

Answer this question