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

Struggling to get Power to go up in SB fan game?

Asked by 1 year ago

I'm making an SB fan game and I need help with my IntValue going up Im making a killstreak glove so basically I want it to Gain 1 power every kill. There are multiple scripts that have aspects of this so it might take a while to find the issue, If you are actually taking time out of your day to help me out you deserve so the best life ever. I don't expect it to be anythng complicated probably just a typo. Thanks for your help:

Script one: Located in PlayerHit (IntValue) which is located in ServerStorage

local TimeToDeath = 60
local pir = script.Parent.Parent
local humanoid = pir:FindFirstChild("Humanoid")
local ePIr = script.Parent.Value
while wait(0.1) do
    TimeToDeath = TimeToDeath - 0.1
    if humanoid then
        if TimeToDeath > 0 then
            humanoid.Died:Connect(function)
            for i,v in pairs(game. Workspace:GetChildren()) do
                if v:lsA("Model") then
                    if v and v.Name == ePIr then
                        if game.Players:GetPlayerFromCharacter(v).Backpack:FindFirstChild("Killstreak")then
                            game.Players:GetPlayerFromCharacter(v).Backpack.Killstreak.Handle.HitHandler.Power.Value+=1
                            script.Parent:Destroy()
                            break
                        end
                    end
                end
            end
        end)
        else
        script.Parent:Destroy()
        break
        end
    end
end

Script 2 located in the Handle of the killstreak Tool, has a child which is called Power and it is an IntValue

if hit.Parent:FindFirstChild("Humanoid") then
        local eChar = hit.Parent
        local plrChar = Tool.Parent

        local eHumanRootPart = eChar:FindFirstChild("HumanoidRootPart")
        local plrHumanRootPart = plrChar:FindFirstChild("HumanoidRootPart")

        if plrHumanRootPart and eHumanRootPart then
            script.Disabled = true
            eChar.Humanoid.Sit = true

            local force = Instance.new("BodyVelocity", eHumanRootPart)
            force.MaxForce = Vector3.new(2,2,2) * math.huge
            local direction = (eHumanRootPart.CFrame.Position - plrHumanRootPart.CFrame.Position).Unit
            force.Velocity = (direction + Vector3.new(0,1,0)).Unit * Power.Value

            local rotation = Instance.new("BodyAngularVelocity", eHumanRootPart)
            rotation.AngularVelocity = Vector3.new(1, 1, 1) * math.pi * math.random(1,5)
            rotation.MaxTorque = Vector3.new(2,2,2) * math.huge
            rotation.P = 5000
--problem might be somewhere here down

            local playerHit = game.ServerStorage:FindFirstChild("PlayerHit")
            if playerHit then
                if eChar:FindFirstChild("PlayerHit") then
                else
                    local clonedPlrHit = playerHit:Clone()
                    clonedPlrHit.Value = plrChar.Name
                    clonedPlrHit.Parent = eChar
                end
            end

            wait(0.35)
            force:Destroy()
            rotation:Destroy()
            eChar.Humanoid.Sit = false

            local player = game.Players:GetPlayerFromCharacter(Tool.Parent)
            player.leaderstats.Slaps.Value = player.leaderstats.Slaps.Value + 1
        end
        hitChars[hit.Parent] = true
        wait(2)
        script.Disabled = false
        hitChars[hit.Parent] = nil
    end
end)

script.Power.Changed:Connect(function()
    Power.Value = Power.Value
end)

1 answer

Log in to vote
0
Answered by 1 year ago

On line 10 of the first script you have a space where game. Workspace it should be like this game.Workspace I don't know if this will cause your script not to work but that I might be the fix. Also are there any errors?? Hope this helps!!

Ad

Answer this question