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

How to fix the killstreak sword not giving boost (?)

Asked by 1 year ago

Im making a sword where each time you get a kill, a IntValue changes by 1, which for example the IntValues value Is 3 (Which equals to 3 kills) you get a small boost, but It appears to do nothing

Script:

local Tool = script.Parent
local SoundFolder = Tool.Sounds
local SlashAttack
local DamagePerSlash = 20
local Boolens = {
    Debounce = false,
    CanDamage = false
}
local Animations = { ---Oh boi there Is alot
    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)

---Phases---
if Tool.Kills.Value == 3 then
    DamagePerSlash = 25
end
if Tool.Kills.Value == 5 then
    DamagePerSlash = 30
    Tool.Parent.Humanoid.WalkSpeed = 20
    local ThemeSong = Instance.new("Sound")
    ThemeSong.Parent = Tool.Parent.Torso
    ThemeSong.Name = "ThemeSong"
    ThemeSong.Volume = 3
    ThemeSong.Looped = true
    ThemeSong.SoundId = "rbxassetid://10033782180"
    ThemeSong:Play()
end
if Tool.Kills.Value == 15 then
    DamagePerSlash = 35
    Tool.Parent.Humanoid.WalkSpeed = 30
    local ThemeSong = Instance.new("Sound")
    ThemeSong.Parent = Tool.Parent.Torso
    ThemeSong.Name = "ThemeSong"
    if Tool.Parent.Torso:FindFirstChild("ThemeSong") then
        ThemeSong.Volume = 3
        ThemeSong.Looped = true
        ThemeSong.SoundId = "rbxassetid://10239133106"
        ThemeSong:Play()
    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(DamagePerSlash)
                    if humanoid.Health == 0 then
                        SoundFolder["Kill Get"]:Play()
                        Tool.Kills.Value = Tool.Kills.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(DamagePerSlash)
            if NPCHumanoid.Health == 0 then
                SoundFolder["Kill Get"]:Play()
                Tool.Kills.Value = Tool.Kills.Value + 1
            end
        end
    end
end)
0
what does the error say? CookieTheElfy 0 — 1y
0
i dont see any force or bodyMovers to push the player Puppynniko 1059 — 1y

2 answers

Log in to vote
0
Answered by
lamgogo 56
1 year ago
Edited 1 year ago

So i have a way but its pretty inefficient First a script will detect the player name who kill them after they die,then get all the players and find the killer: Here is the local script(in starter player's player script)

game.workspace.Players.LocalPlayer.Character.Humanoid.Died:Connect(function() Local kill = game.workspace.Players.LocalPlayer.Character.Humanoid:FindFirstChild("creator") Local killName = kill.Value.Name For i,v in pairs(game.Players:GetPlayers()) do If v.Name == killName then --fire some server with player name in it,the "Remote" down here is the remote event Game.ReplicatedStorage.Remote:FireServer(killName) end end end)

In the sword script:

Game.ReplicatedStorage.Remote.OnServerEvent:Connect(function(plr,name) if name == plr.Name then --Do the increase damage stuff here end end)

I write this on web so there might be some error like missing end or smth,but the script might work

Ad
Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

Use GetPropertyChangedSignal:

Tool.Kills:GetPropertyChangedSignal("Value"):Connect(function()
    --Phases here
end)

Answer this question