pawnz
|
  |
| Joined: 22 Feb 2010 |
| Total Posts: 286 |
|
|
| 10 Sep 2015 06:33 PM |
Would it be possible to have a script that puts a SelectionBox on a player that touches a brick that the script is in?
Kind of like a scanner, while touching the brick you have a selection box around your character and when not touching the brick it removes the selection box that it put on you?
-- Even better if the selection boxes could be around the each of the body parts so that its not just a giant box around your character but more form fitting and realistic? |
|
|
| Report Abuse |
|
|
pawnz
|
  |
| Joined: 22 Feb 2010 |
| Total Posts: 286 |
|
| |
|
pawnz
|
  |
| Joined: 22 Feb 2010 |
| Total Posts: 286 |
|
| |
|
|
| 10 Sep 2015 06:43 PM |
Yes, you can do this.
"This is life, truthfully I just want to fly some kites, Grab Salem and Slater and go around, riding bikes" - Tyler |
|
|
| Report Abuse |
|
|
|
| 10 Sep 2015 06:44 PM |
Absolutely, you'll need these two events:
http://wiki.roblox.com/index.php?title=API:Class/BasePart/Touched http://wiki.roblox.com/index.php?title=API:Class/BasePart/TouchEnded
Just use the touched event to detect and characters touching it, and fill them up with selectionboxes (if they don't have any already). On touchended just clear them |
|
|
| Report Abuse |
|
|
pawnz
|
  |
| Joined: 22 Feb 2010 |
| Total Posts: 286 |
|
|
| 10 Sep 2015 06:45 PM |
| Would it work like other FX items in basic objects like fire/sparkles/smoke? |
|
|
| Report Abuse |
|
|
|
| 10 Sep 2015 06:46 PM |
@pawnz
Yes, it will, Just as long as you can add it into each body part and remove it.
"This is life, truthfully I just want to fly some kites, Grab Salem and Slater and go around, riding bikes" - Tyler |
|
|
| Report Abuse |
|
|
|
| 10 Sep 2015 06:47 PM |
| SelectionBoxes have an 'adornee' property, which you set to the object which you want the selectionbox to surround. Other than that, it would be fairly similar. |
|
|
| Report Abuse |
|
|
pawnz
|
  |
| Joined: 22 Feb 2010 |
| Total Posts: 286 |
|
|
| 10 Sep 2015 07:18 PM |
So if I have.
local lol = Instance.new("SelectionBox") lol.Parent = part
Obviously this does not work, but how would I tell the script that I want it to make a selection box? |
|
|
| Report Abuse |
|
|
|
| 10 Sep 2015 07:20 PM |
You're 99% there
local lol = Instance.new("SelectionBox") lol.Parent = part lol.Adornee = part |
|
|
| Report Abuse |
|
|
pawnz
|
  |
| Joined: 22 Feb 2010 |
| Total Posts: 286 |
|
|
| 10 Sep 2015 07:23 PM |
I got this to work:
function ontouch(part) if part.Name ~= "Head" or "Left Arm" or "Right Arm" or "Right Leg" or "Left Leg" or "Torso" then local lol = Instance.new("SelectionBox") lol.Parent = part lol.Adornee = part script.Parent.Yell1:play() end end script.Parent.Touched:connect(ontouch)
-- However now I need to add in some script lines to remove them after the "touching" has ended. |
|
|
| Report Abuse |
|
|
|
| 10 Sep 2015 07:24 PM |
http://wiki.roblox.com/index.php?title=API:Class/BasePart/TouchEnded
Same idea as touched, but fires when a touch ends |
|
|
| Report Abuse |
|
|
pawnz
|
  |
| Joined: 22 Feb 2010 |
| Total Posts: 286 |
|
|
| 10 Sep 2015 07:25 PM |
And also I see that SelectionBox has a Color3 value to change its color, how would one go about typing the color code change properly?
lol.Color3 = x
--Seen in the properties window as: Color3 | [1,1,1] |
|
|
| Report Abuse |
|
|
|
| 10 Sep 2015 07:28 PM |
lol.Color3 = Color3.new(r/255,g/255,b/255)
|
|
|
| Report Abuse |
|
|
pawnz
|
  |
| Joined: 22 Feb 2010 |
| Total Posts: 286 |
|
|
| 10 Sep 2015 07:31 PM |
Script as of now:
function ontouch(part) if part.Name ~= "Head" or "Left Arm" or "Right Arm" or "Right Leg" or "Left Leg" or "Torso" then local scn = Instance.new("SelectionBox") scn.name = "DeBatCaiv" scn.Color3 = ??? scn.Parent = part scn.Adornee = part end end
script.Parent.Touched:connect(ontouch) |
|
|
| Report Abuse |
|
|
pawnz
|
  |
| Joined: 22 Feb 2010 |
| Total Posts: 286 |
|
|
| 10 Sep 2015 07:39 PM |
--update --------
function ontouch(part) if part.Name ~= "Head" or "Left Arm" or "Right Arm" or "Right Leg" or "Left Leg" or "Torso" then local scn = Instance.new("SelectionBox") scn.Name = "DeBatCaiv" scn.Color3 = Color3.new(255,255,0) scn.Transparency = 0.1 scn.LineThickness = 0.02 scn.Parent = part scn.Adornee = part end end
script.Parent.Touched:connect(ontouch)
-------- --update
So I know that "Workspace.Part.TouchEnded" is how I tell it when to remove the Outlines, but how do I get the script to "remove the outlines"? |
|
|
| Report Abuse |
|
|
|
| 10 Sep 2015 07:41 PM |
http://wiki.roblox.com/index.php?title=Color3
e.g. if you wanted your selectionbox to be blue: scn.Color3 = Color3.new(0,0,1) (The same as (0/255,0/255,255/255))
Also you've written your conditional slightly incorrectly. Lua breaks 'if' statements up into each 'or' component and compares them individually. In other words: if part.Name ~= "Head" or "Left Arm" or "Right Arm" or "Right Leg" or "Left Leg" or "Torso" then Becomes if (part.Name ~= "Head") or ("Left Arm") or ("Right Arm") or ("Right Leg") or ("Left Leg") or ("Torso") then
Anything which isn't 'nil' or 'false' is true, so if the part isn't head, this is seen as: if (false) or (true) or (true) or (true) or (true) or (true) then Which will always be true
In other words your conditional is always going to be 'successful' from the way you've organised it |
|
|
| Report Abuse |
|
|
|
| 10 Sep 2015 07:43 PM |
Remember to divide by 255 for your colours; color3 takes numbers from 0-1 rather than 0-255
The argument for TouchEnded is the same as Touched in that it gives the part which 'stops touching' as it's argument. So you'll want to do a similar thing as in creating the selectionboxes, but instead check for them and remove them (if they're found) |
|
|
| Report Abuse |
|
|
pawnz
|
  |
| Joined: 22 Feb 2010 |
| Total Posts: 286 |
|
|
| 10 Sep 2015 08:04 PM |
"check for them and remove them (if they're found)"
How would I write that? |
|
|
| Report Abuse |
|
|
pawnz
|
  |
| Joined: 22 Feb 2010 |
| Total Posts: 286 |
|
|
| 10 Sep 2015 08:06 PM |
| Also I just used my existing constant SelectionBox that I have in another part to edit it's values such as its color and line size to get my desired values. |
|
|
| Report Abuse |
|
|
|
| 10 Sep 2015 08:08 PM |
where part is the body part;
for _,v in pairs(part:GetChildren()) do if v:IsA("SelectionBox") then v:Destroy() end end |
|
|
| Report Abuse |
|
|
pawnz
|
  |
| Joined: 22 Feb 2010 |
| Total Posts: 286 |
|
|
| 10 Sep 2015 08:26 PM |
Ok so I now have this:
function ontouch(part) if part.Name ~= "Head" or "Left Arm" or "Right Arm" or "Right Leg" or "Left Leg" or "Torso" then local scn = Instance.new("SelectionBox") scn.Name = "DeBatCaiv" scn.Color3 = Color3.new(255, 0, 0) scn.Transparency = 0.1 scn.LineThickness = 0.01 scn.Parent = part scn.Adornee = part end end
function onTouchEnded:connect(part) --? "onTouchEnded" is not a thing apparently. if part.Name ~= "Head" or "Left Arm" or "Right Arm" or "Right Leg" or "Left Leg" or "Torso" then for _,v in pairs(part:GetChildren()) do if v:IsA("SelectionBox") then v:Destroy() end end end end
script.Parent.Touched:connect(ontouch) |
|
|
| Report Abuse |
|
|
|
| 10 Sep 2015 08:36 PM |
You want your connection line to be:
script.Parent.TouchEnded:connect(function(part) And close it with end)
Also read up a bit about what I said about conditionals |
|
|
| Report Abuse |
|
|
pawnz
|
  |
| Joined: 22 Feb 2010 |
| Total Posts: 286 |
|
|
| 10 Sep 2015 08:39 PM |
| Works perfectly! Thank you everyone who helped! |
|
|
| Report Abuse |
|
|