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

I am trying to make a multi value but I don't understand what I did here can someone help?

Asked by
WN0820 11
4 years ago

I am trying to make it that when the multi value is at 2 then it gives me +1 more. If you can help me I am happy I tried changing it here it is from my change

local plr = script.Players.LocalPlayer
local tool = script.Parent
local anim = tool:WaitForChild("Using")
local player = tool.Parent:IsA("Model") and game.Players:GetPlayerFromCharacter(tool.Parent) or tool.Parent.Parent
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local humR = char:WaitForChild("HumanoidRootPart")
local deb = false 

tool.Activated:Connect(function()
    local stats = player:FindFirstChild("Stats")
    if stats then
        local Multi = stats:FindFirstChild("Multi")
        local meditate = stats:FindFirstChild("PunchPower")
        if meditate and deb == false then
            deb = true
            local animPlay = hum:LoadAnimation(anim)
            animPlay:Play()
            local selected
            for i,v in pairs(workspace:WaitForChild("Zones"):GetChildren())do
                if v:FindFirstChild("Requires") and v:FindFirstChild("Value") and v:FindFirstChild("Stats") and v.Stats.Value == "PunchPower" then
                    if (humR.Position-v.Position).Magnitude <= v.Magnitude.Value and meditate.Value >= v.Requires.Value then
                        selected = v
                    end
                end 
            end
            if selected == nil then
                if Multi.Value >= 2 then
                    meditate.Value = Multi.Value +1
                else
                    meditate.Value = 1

                    meditate.Value = meditate.Value + 1
                meditate.Value = meditate.Value + selected.Value.Value
            end
            wait(1)
            deb = false
                end
        end
    end
end)

Answer this question