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

making tool disabled if player touches brick?

Asked by
mehssi 20
9 years ago

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

Log in to vote
0
Answered by 9 years ago

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)
Ad

Answer this question