Ad
Log in to vote
0

How can I fix my dice tool not giving effects?

Asked by 5 days ago
Edited 5 days ago

Hello!

I made a dice tool that gives you either bad or good boost

The lower the number, the bad the effect Is, and the higher the number, the good the effect Is

The problem Is that, when the tool Is activated the dice Is suppose to say the users name and give them a effect but Instead, says the humanoid name and won't give the effect, I also saw a error In output which says:

Humanoid is not a valid member of Backpack "Players.imnotaguest1121.Backpack"

Please help

Script:

local Tool = script.Parent
local Debounce = false

Tool.Activated:Connect(function()
    if not Debounce then
        Debounce = true
        local Dice = Tool.Handle:Clone()
        local VectorForce = Instance.new("VectorForce",Dice)
        local Attachment = Instance.new("Attachment",Dice)
        VectorForce.Attachment0 = Attachment
        VectorForce.Force = Vector3.new(0,0,1000)
        Dice.Parent = game.Workspace
        Dice.Name = "Dice"
        Dice.Position = Tool.Handle.Position
        Dice.Orientation = Tool.Handle.Orientation
        Dice.CanCollide = true
        game:GetService("Debris"):AddItem(Dice,10)
        game:GetService("Debris"):AddItem(Attachment,0.5)
        game:GetService("Debris"):AddItem(VectorForce,0.5)
        wait(2)
        local GoodEffectAndBadEffect = math.random(1,6)

        if GoodEffectAndBadEffect == 1 then
            game:GetService("Chat"):Chat(Dice,Tool.Parent.Humanoid.Name.."Recived DEATH.",Enum.ChatColor.White)
            wait(2)
            Tool.Parent.Humanoid.Health = 0
        end
        if GoodEffectAndBadEffect == 2 then
            game:GetService("Chat"):Chat(Dice,Tool.Parent.Humanoid.Name.."Recived Stone Age",Enum.ChatColor.White)
            wait(2)
            Tool.Parent.Humanoid.WalkSpeed = 0
            Tool.Parent.Humanoid.JumpPower = 0
        end
        if GoodEffectAndBadEffect == 3 then
            game:GetService("Chat"):Chat(Dice,Tool.Parent.Humanoid.Name.."Recived Temporarily body freeze",Enum.ChatColor.White)
            wait(2)
            Tool.Parent.Head.Anchored = true
            Tool.Parent["Left Arm"].Anchored = true
            Tool.Parent["Right Arm"].Anchored = true
            Tool.Parent["Left Leg"].Anchored = true
            Tool.Parent["Right Leg"].Anchored = true
            Tool.Parent.Torso.Anchored = true
            wait(3)
            Tool.Parent.Head.Anchored = true
            Tool.Parent["Left Arm"].Anchored = false
            Tool.Parent["Right Arm"].Anchored = false
            Tool.Parent["Left Leg"].Anchored = false
            Tool.Parent["Right Leg"].Anchored = false
            Tool.Parent.Torso.Anchored = false
        end
        if GoodEffectAndBadEffect == 4 then
            game:GetService("Chat"):Chat(Dice,Tool.Parent.Humanoid.Name.."Recived Lazy legs",Enum.ChatColor.White)
            wait(2)
            Tool.Parent.Humanoid.WalkSpeed = 10
            Tool.Parent.Humanoid.JumpPower = 30
        end
        if GoodEffectAndBadEffect == 5 then
            game:GetService("Chat"):Chat(Dice,Tool.Parent.Humanoid.Name.."Recived Nothing lol",Enum.ChatColor.White)
        end
        if GoodEffectAndBadEffect == 6 then
            game:GetService("Chat"):Chat(Dice,Tool.Parent.Humanoid.Name.."Recived Speedy",Enum.ChatColor.White)
            wait(2)
            Tool.Parent.Humanoid.WalkSpeed = 32
        end
        if GoodEffectAndBadEffect == 7 then
            game:GetService("Chat"):Chat(Dice,Tool.Parent.Humanoid.Name.."Recived 2000 Health",Enum.ChatColor.White)
            wait(2)
            Tool.Parent.Humanoid.MaxHealth = 2000
            Tool.Parent.Humanoid.Health = 2000
        end
        if GoodEffectAndBadEffect == 8 then
            game:GetService("Chat"):Chat(Dice,Tool.Parent.Humanoid.Name.."Recived God-Like",Enum.ChatColor.White)
            wait(2)
            Tool.Parent.Humanoid.WalkSpeed = 50
            Tool.Parent.Humanoid.MaxHealth = 4000
            Tool.Parent.Humanoid.Health = 4000
        end
        if GoodEffectAndBadEffect == 9 then
            game:GetService("Chat"):Chat(Dice,Tool.Parent.Humanoid.Name.."Recived God",Enum.ChatColor.White)
            wait(2)
            Tool.Parent.Humanoid.WalkSpeed = 70
            Tool.Parent.Humanoid.MaxHealth = 8000
            Tool.Parent.Humanoid.Health = 8000
        end
        if GoodEffectAndBadEffect == 10 then
            game:GetService("Chat"):Chat(Dice,Tool.Parent.Humanoid.Name.."Recived G.O.D",Enum.ChatColor.White)
            wait(2)
            local ForceField = Instance.new("ForceField",Tool.Parent)
            ForceField.Visible = false
            Tool.Parent.Humanoid.WalkSpeed = 100
            Tool.Parent.Humanoid.MaxHealth = 14000
            Tool.Parent.Humanoid.Health = 14000
        end
        wait(2)
        Debounce = false
        Tool:Destroy()
    end
end)

Answer this question