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: Has roblox broken the touched event?

Previous Thread :: Next Thread 
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
03 Aug 2015 08:54 AM
I just ran a 3 line script, for when you touch a brick it prints something. Nothing printed, but it did in studio.

Roblox broke it? same update as "function ot enabled"?
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
03 Aug 2015 08:55 AM
by studio i mean solo mode
Report Abuse
WoolHat is online. WoolHat
Joined: 19 May 2013
Total Posts: 1873
03 Aug 2015 09:01 AM
Function not enabled has been something run through outputs since about the release of Win10. It doesn't break any scripts (as far as I know), so just ignore it.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
03 Aug 2015 09:04 AM
That isn't the problem.

Touched isn't working...
Report Abuse
loomis0523BC is not online. loomis0523BC
Joined: 08 Jan 2015
Total Posts: 764
03 Aug 2015 09:15 AM
i found this works more cleaner for my scripting

script.Parent.Touched:connect(function()


end)
Report Abuse
Meowcatmaster is not online. Meowcatmaster
Joined: 20 Oct 2012
Total Posts: 769
03 Aug 2015 09:18 AM
Works more Cleaner?... Ow. My head.
Did you mean works better or more effective?

And I find doing that better as well.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
03 Aug 2015 09:20 AM
Well? Does touched work for anyone else in play mode
Report Abuse
WoolHat is online. WoolHat
Joined: 19 May 2013
Total Posts: 1873
03 Aug 2015 09:23 AM
Oh my, sorry I skimmed D:

script.Parent.Touched:connect(function()
--code here
end)

function whateverfunction()
--code here
end

script.Parent.Touched:connect(whateverfunction)

If neither of those are working, post the code and we can probably figure it out. Again, sorry for that first response, lol. Early morning
Report Abuse
WoolHat is online. WoolHat
Joined: 19 May 2013
Total Posts: 1873
03 Aug 2015 09:23 AM
And yes, it has been working for me perfectly fine.
Report Abuse
Robertoman is not online. Robertoman
Joined: 10 May 2007
Total Posts: 6369
03 Aug 2015 09:24 AM
Yes works perfectly for me in play mode.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
03 Aug 2015 09:25 AM
game.Workspace.WEST.Touched:connect(function(hit)
print("NoPrinterino")
end)

no printing in play mode

prints in test mode
Report Abuse
CrowClaws is not online. CrowClaws
Joined: 04 Jul 2010
Total Posts: 4466
03 Aug 2015 09:27 AM
is game.Wokrpsace.WEST
even being touched?
does "WEST" exist or are there two wests?
Report Abuse
Robertoman is not online. Robertoman
Joined: 10 May 2007
Total Posts: 6369
03 Aug 2015 09:29 AM
Try this, just for sag:

workspace.WEST.Touched:connect(function(hit)
print("NoPrinterino")
end)
Report Abuse
CrowClaws is not online. CrowClaws
Joined: 04 Jul 2010
Total Posts: 4466
03 Aug 2015 09:35 AM
print(workspace:FindFirstChild"WEST")
does it exist?
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
03 Aug 2015 09:58 AM
It is important to realize what

function example()

end

whatever.Event:connect(example)

...and...

whatever.Event:connect(function()

end)

are capable of.


In the first one, a function is created, malleable, and can be used many time.
Int he second example, a final static function is create, not malleable, therefore can only be used once in a certain way.

For extendability, it is good to know how to take control.

Let's take the Touched event for example.
game.Workspace.Part.Touched

We have many parts that kill a player. It is easy just to...

script.Parent.Touched:connect(function(hit)
if(hit.Parent)then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if(plr)then
plr.Character.Humanoid:TakeDamage(plr.Character.Humanoid.MaxHealth)
end
end
end)

Now instead of creating all of these scripts inside of all these parts...
(Let's take the example of 100)

We can batch over all of these parts and apply a single function to them. (and not 100 functions (and not in 100 scripts))

local onTouch = function(hit)
if(hit.Parent)then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if(plr)then
plr.Character.Humanoid:TakeDamage(plr.Character.Humanoid.MaxHealth)
end
end
end

local apply = function(event, funct)
event:connect(funct)
end

for i, v in pairs(script.Parent:GetChildren())do
if(v:IsA("Part"))then
--Note you CAN NOT make a RBXScriptSignal stay in a for loop.
--It will simply just go away. So I had to make the apply function
apply(v.Touched, onTouch)
end
end
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