generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: CanCollide + Touched Function issue

Previous Thread :: Next Thread 
Weaselover2 is not online. Weaselover2
Joined: 29 Aug 2013
Total Posts: 130
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
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
27 Jan 2017 08:43 AM
Parts can't be touched when you can't collide I believe.
Report Abuse
Weaselover2 is not online. Weaselover2
Joined: 29 Aug 2013
Total Posts: 130
27 Jan 2017 08:46 AM
Good point. What would the proper script be, then?

Report Abuse
XCVlll is not online. XCVlll
Joined: 23 Oct 2008
Total Posts: 963
27 Jan 2017 08:47 AM
^yeah they can
Report Abuse
XCVlll is not online. 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
Weaselover2 is not online. Weaselover2
Joined: 29 Aug 2013
Total Posts: 130
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 is not online. 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
Weaselover2 is not online. Weaselover2
Joined: 29 Aug 2013
Total Posts: 130
27 Jan 2017 08:59 AM
Sorry, noob scripter, what is magnitude?
Report Abuse
XCVlll is not online. 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
Weaselover2 is not online. Weaselover2
Joined: 29 Aug 2013
Total Posts: 130
27 Jan 2017 09:08 AM
The shape is Block, so region3?
Report Abuse
XCVlll is not online. 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
Weaselover2 is not online. Weaselover2
Joined: 29 Aug 2013
Total Posts: 130
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image