|
| 27 Jan 2017 08:02 AM |
I am trying to script a part so that when it is touched by the player, then CanCollide is set to true but otherwise it is false This is what I have right now:
Part = script.Parent Part.CanCollide = false function onTouch(hit) local Parent = hit.Parent if game.Players:GetPlayerFromCharacter(Parent) then Part.CanCollide = true end end
Part.Touched:connect(onTouch)
Help is aprecciated |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2017 08:43 AM |
| Parts can't be touched when you can't collide I believe. |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2017 08:46 AM |
Good point. What would the proper script be, then?
|
|
|
| Report Abuse |
|
|
XCVlll
|
  |
| Joined: 23 Oct 2008 |
| Total Posts: 963 |
|
| |
|
XCVlll
|
  |
| Joined: 23 Oct 2008 |
| Total Posts: 963 |
|
|
| 27 Jan 2017 08:49 AM |
script.Parent.Touched:connect(function(hit) if script.Parent.CanCollide then script.Parent.CanCollide = false else script.Parent.CanCollide = true end end) |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2017 08:52 AM |
In the game, I want the Fireballs to pass through it, but when the player attempts to touch it then CanCollide is true.
Thanks - Weaselover2 |
|
|
| Report Abuse |
|
|
XCVlll
|
  |
| Joined: 23 Oct 2008 |
| Total Posts: 963 |
|
|
| 27 Jan 2017 08:55 AM |
| why would you make it toggle between true and false then? that wouldn't really do it, i suggest using magnitude |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2017 08:59 AM |
Sorry, noob scripter, what is magnitude?
|
|
|
| Report Abuse |
|
|
XCVlll
|
  |
| Joined: 23 Oct 2008 |
| Total Posts: 963 |
|
|
| 27 Jan 2017 09:06 AM |
| the difference between two positions represented in a sphere, well use either that or Region3 depending on the shape you need |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2017 09:08 AM |
| The shape is Block, so region3? |
|
|
| Report Abuse |
|
|
XCVlll
|
  |
| Joined: 23 Oct 2008 |
| Total Posts: 963 |
|
|
| 27 Jan 2017 09:25 AM |
| yeah look at the wiki for the region3 constructor |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2017 09:29 AM |
| Wait, just out of curiousity... Why is the CanCollide always set to on in this script? Part = script.Parent function onTouch(hit) local Children = hit.Parent:GetChildren() local Parent = hit.Parent if hit.Parent:FindFirstChild('Humanoid') then Part.CanCollide = true end end ############################# ########################################### if otherpart.Parent:FindFirstChild('Humanoid') then Part.CanCollide = false end end) Thanks -Weaselover2 |
|
|
| Report Abuse |
|
|