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

01function onTouched(hit1)
02local torso1 = hit1.Parent:findFirstChild("Torso")
03    if torso1~=nil then
04        Y = game.Players:playerFromCharacter(hit1.Parent)
05        if Y.TeamColor==BrickColor.new("Deep blue")then
06-- i dont know what to put here
07 
08        end
09    end
10end

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:

01-- Script is inside the part that gets touched
02 
03local color = BrickColor.new("Deep blue")
04 
05script.Parent.Touched:connect(function(hit)
06    local p = game.Players:GetPlayerFromCharacter(hit.Parent)
07    if p then
08        if p.TeamColor == color then
09            local tool = hit.Parent:FindFirstChild("ToolName") -- or, p.Backpack:FindFirstChild("ToolName"), so you can disable it even if it's unequipped
10            if tool then
11                tool.Enabled = false
12            end
13        end
14    end
15end)
Ad

Answer this question