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

Can someone help me with this script. When I touch the brick it doesn't work?

function hit(part) if hit == nil then return end h = game.Players:GetPlayerFromCharacter(part.Parent) if h ~= nil then c = h.Backpack:GetChildren() for i=1,#c do c[i]:remove() end end end

script.Parent.Touched:connect(hit)

Please help I want make a script that when player touches the brick their tools rest. Thanks

1 comment

0

don't get a random script from the internet, please post your broken script

1 answer

(first off, use code blocks and more depth into your question next time)

i tested it, and it works fine, until you do so while HOLDING a tool, the reason for this is because whenever a tool is being held, its moved out of the backpack, and into the character, so be sure to deal with that too

also :connect() is depracted, use :Connect() same for :remove(), use :Destroy()

function Touch(hit)
	if hit and h.Parent and hit.Parent:FindFirstChildOfClass("Humanoid") then
		game.Players[h.Parent.Name].Backpack:ClearAllChildren()
		local CharTool = FindFirstChildOfClass(_HopperBin_) or h.Parent_FindFirstChildOfClass(_Tool_)
		if CharTool then
			CharTool:Destroy()
		end
	end
end

script.Parent.Touched:Connect(Touch)

1 comment

0

Thats not what he wants... he wants the tools to get reset like the player died, but not with killing him

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