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

Why Isn't my sword not giving kills, and also why Isn't not going phases?

Asked by 2 years ago

I am making a sword similar to a glove from Slap Battles called "Killstreak", the more kills you get the more stronger you are, I made a sword script that each time you get a kill, the IntValue (Which Is called "Kills") are raised by 1, but as the title says, It doesn't change, also when I reach a certain phase like Phase 1 which I get a small boost, It doesn't apply

Main script (Sword, Server-Sided):

local Tool = script.Parent
local SoundFolder = Tool.Sounds
local SlashAttack
local KillsValue = Tool.Kills ---This Is a IntValue
local Boolens = {
    Debounce = false,
    CanDamage = false
}
local Animations = {
    EquipAnimation = Tool.EquipAnimation,
    Idle = Tool.Idle,
    Slash = Tool.Slash,
}

Tool.Equipped:Connect(function()
    SoundFolder.Unsheath:Play()
    local Humanoid = Tool.Parent.Humanoid

    local EquipAnimationTrack = Humanoid:FindFirstChild("Animator"):LoadAnimation(Animations.EquipAnimation)
    EquipAnimationTrack:Play()
    task.wait(0.30)
    local Idle = Humanoid:FindFirstChild("Animator"):LoadAnimation(Animations.Idle)
    Idle:Play()
    Tool.Unequipped:Connect(function()
        Idle:Stop()
    end)
end)

Tool.Activated:Connect(function()
    if not Boolens.Debounce then
        Boolens.Debounce = true
        Boolens.CanDamage = true
        SoundFolder.Slash:Play()
        print("The tool has been clicked")
        local Humanoid = Tool.Parent.Humanoid

        SlashAttack = Humanoid:FindFirstChild("Animator"):LoadAnimation(Animations.Slash)
        SlashAttack:Play()
        task.wait(0.5)
        Boolens.CanDamage = false
        wait(1)
        Boolens.Debounce = false
    end
end)

Tool.Handle.Touched:Connect(function(hit)
    local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
    if Player then
        local player1 = game.Players:GetPlayerFromCharacter(Tool.Parent)
        local player2 = game.Players:GetPlayerFromCharacter(hit.Parent)

        if (player1 ~= nil) and (player2 ~= nil) then
            local humanoid = (player2.Character or player2.CharacterAdded:Wait()):FindFirstChildWhichIsA("Humanoid")

            if (player1.TeamColor ~= player2.TeamColor) then
                if (humanoid ~= nil) and Boolens.CanDamage == true then
                    Boolens.CanDamage = false
                    humanoid:TakeDamage(30)
                    if humanoid.Health == 0 then
                        SoundFolder["Kill Get"]:Play()
                        KillsValue.Value = KillsValue.Value + 1
                    end
                end
            end
        end
    else
        local NPCHumanoid = hit.Parent:WaitForChild("Humanoid")
        if NPCHumanoid and Boolens.CanDamage == true then
            Boolens.CanDamage = false
            NPCHumanoid:TakeDamage(30)
            if NPCHumanoid.Health == 0 then
                SoundFolder["Kill Get"]:Play()
                KillsValue.Value = KillsValue.Value + 1
            end
        end
    end
end)

Phase script (Inside the IntValue, Server Sided):

local Tool = script.Parent.Parent.Parent
local IntValue = script.Parent

if IntValue.Value == 3 then
    Tool.Parent.Humanoid.WalkSpeed = 18
end

if IntValue.Value == 5 then
    Tool.Parent.Humanoid.WalkSpeed = 20
    local ThemeSong = Instance.new("Sound")
    ThemeSong.Name = "ThemeSong"
    ThemeSong.Parent = Tool.Parent.Torso
    ThemeSong.Looped = true
    ThemeSong.Volume = 3
    ThemeSong.SoundId = "rbxassetid://10239133106"
    ThemeSong:Play()
end

1 answer

Log in to vote
0
Answered by
enes223 327 Moderation Voter
2 years ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Ad

Answer this question