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

How would i make this part hurt others when they touch it but not hurt me?

Asked by
Damo999 182
10 years ago

Basically what the title says i can't figure out how to do this. How would i make the part hurt others but not hurt me when i touch it, i tried this script but it doesn't work.

01wait(5)
02player = game.Players.LocalPlayer
03mouse = player:GetMouse()
04safe = game.Workspace.Player -- i used safe as the vairable to distingush between who gets hurt and who doesn't
05 
06print("GO")
07 
08detectionPad                = Instance.new("Part",player.Character)
09detectionPad.Anchored       = true
10detectionPad.CanCollide     = false
11detectionPad.BrickColor     = BrickColor.new("Really blue")
12detectionPad.Transparency   = .4
13detectionPad.FormFactor     = Enum.FormFactor.Custom
14detectionPad.Size           = Vector3.new(10, 0.5, 10)
15detectionPad.CFrame         = detectionPad.CFrame*CFrame.Angles(1,0,0)
View all 30 lines...

1 answer

Log in to vote
0
Answered by
fai1bro 25
10 years ago

I'm not sure if you can do that with just one script, but if you are willing to have two scripts then do this.

01permission = {"Player"}
02 
03function checkOkToLetIn(name)
04    for i = 1,#permission do
05        if (string.upper(name) == string.upper(permission[i])) then return true end
06    end
07    return false
08end
09 
10local Door = script.Parent
11 
12function onTouched(hit)
13    local human = hit.Parent:findFirstChild("Humanoid")
14    if (human ~= nil ) then
15        if (checkOkToLetIn(human.Parent.Name)) then
View all 22 lines...

Put this script as a child of your script and disable this script, modify your script to copy this script then past it into the brick and enable it (enabling is a behavior property). Here is an example of how to clone something:

1local part = Instance.new("Part")
2part.Parent = game.Workspace
3local clone = part:Clone()
4clone.Parent = game.Workspace
0
bump Damo999 182 — 10y
Ad

Answer this question