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

making tool disabled if player touches brick?

can someone help me make this?

this is the only thing i can do by myself

function onTouched(hit1)
local torso1 = hit1.Parent:findFirstChild("Torso")
	if torso1~=nil then
		Y = game.Players:playerFromCharacter(hit1.Parent)
		if Y.TeamColor==BrickColor.new("Deep blue")then
-- i dont know what to put here

		end
	end
end

please help I am the worst scripter

1 answer

QUICK TIP: A more efficient way of doing your script would be to check for the player straight away.

CODE:

-- Script is inside the part that gets touched

local color = BrickColor.new("Deep blue")

script.Parent.Touched:connect(function(hit)
	local p = game.Players:GetPlayerFromCharacter(hit.Parent)
	if p then
		if p.TeamColor == color then
			local tool = hit.Parent:FindFirstChild("ToolName") -- or, p.Backpack:FindFirstChild("ToolName"), so you can disable it even if it's unequipped
			if tool then
				tool.Enabled = false
			end
		end
	end
end)

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