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

I Tried to make a Low Health unequip all items script but its not working?

Asked by
PhoxGT 0
4 years ago

i need help with this script

script: local char = script.Parent local hum = char.Humanoid

hum.HealthChanged:Connect(function() if hum.Health <= 15 then local Players = game:GetService("Players"

        local player = Players:FindFirstChildOfClass("Humanoid"
            if humanoid then
                local tool = workspace:FindFirstChild("Tool
                    if tool then
                        Humanoid:UnequipTools
                    end
                end
            end
0
I need help PhoxGT 0 — 4y
0
whats the error? SupremeAraeen 2 — 4y
0
You're missing several parentheses Ziffixture 6913 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

So if this were me, then I would write it like this.

local Players = game:GetService("Players")
local character = script.Parent
local humanoid = Character:WaitForChild("Humanoid")

humanoid.HealthChanged:Connect(function(health)
    if (health < 15) then 
        local plrToGet= Players:GetPlayerFromCharacter(character)
        if (not plrToGet) then return end 
        plrToGet.Backpack:ClearAllChildren()
        local equippedTool = character:FindFirstChildOfClass("Tool")
        if (equippedTool) then 
            equippedTool:Destroy()
        end 
    end 
end)

Hoped this helped. If you need any more insight, let me know!

Ad
Log in to vote
0
Answered by
Alphexus 498 Moderation Voter
4 years ago

Humanoid:UnequipTools() is a method so you need to have those parenthesis "()" after it.

Answer this question