Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

3 comments

0

I need help

0

whats the error?

0

You're missing several parentheses

2 answers

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!

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

This discussion is preserved as it was. New answers, comments, and votes are closed.