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: Quick scription O>o

Previous Thread :: Next Thread 
coolfun101 is not online. coolfun101
Joined: 25 Jul 2011
Total Posts: 652
21 Dec 2014 03:30 PM
Is there a way for an ontouch function to work for all things that have the same name O.o

Because i know you can do this for the last line

game.Workspace.Curve.SlideSit.Touched:connect(onTouched)

to define what it has to touch

But is there a way for it to work on any part named SlideSit? or just for something with the same name?
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
21 Dec 2014 03:38 PM
local function Iter(o)
for k,v in pairs(o:GetChildren()) do
Iter(v)
if v.Name=="SlideSit" then
v.Touched:connect(somefunction)
end
end
end
Iter(workspace)
Report Abuse
coolfun101 is not online. coolfun101
Joined: 25 Jul 2011
Total Posts: 652
21 Dec 2014 03:45 PM
Thank you so much elun for trying to help but it gave this error

16:43:16.589 - Attempt to connect failed: Passed value is not a function
16:43:16.590 - Script 'Players.Player1.PlayerGui.LocalScript', Line 5 - local Iter
16:43:16.590 - Script 'Players.Player1.PlayerGui.LocalScript', Line 9
16:43:16.590 - Stack End
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
21 Dec 2014 03:48 PM
Don't make it local?
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
21 Dec 2014 03:51 PM
I don't think there is a 'somefunction' function defined, and that's why it's complaining.
Report Abuse
Ojia is not online. Ojia
Joined: 08 Feb 2012
Total Posts: 650
21 Dec 2014 03:52 PM
Try this

for i,v in pairs (game.Workspace:GetChildren()) do
if(v.Name == "Name here") then
-- Blah blah blah
end
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
21 Dec 2014 03:54 PM
Dude that was even worse than mine, and it only does the top level.
Report Abuse
coolfun101 is not online. coolfun101
Joined: 25 Jul 2011
Total Posts: 652
21 Dec 2014 03:55 PM
xD i am so confused
Report Abuse
coolfun101 is not online. coolfun101
Joined: 25 Jul 2011
Total Posts: 652
21 Dec 2014 03:57 PM
I guess i will just do it the long way oh well


function onTouched(hit)
game.Players.LocalPlayer.Character.Humanoid.Sit = true
end
game.Workspace.SlideSit.Touched:connect(onTouched)

function onTouched(hit)
game.Players.LocalPlayer.Character.Humanoid.Sit = true
end
game.Workspace.SlideSitTwo.Touched:connect(onTouched)

function onTouched(hit)
game.Players.LocalPlayer.Character.Humanoid.Sit = true
end
game.Workspace.SlideSitThree.Touched:connect(onTouched)

....ect ... 37 more to go xD
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
21 Dec 2014 03:58 PM
function onTouched(hit)
game.Players.LocalPlayer.Character.Humanoid.Sit = true
end
game.Workspace.SlideSit.Touched:connect(onTouched)

function onTouched(hit)
game.Players.LocalPlayer.Character.Humanoid.Sit = true
end
game.Workspace.SlideSitTwo.Touched:connect(onTouched)


What are you doing moron
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
21 Dec 2014 03:59 PM
coolfun:

In your example above, you redefine the same function with the same code in it. You don't need to do this.

If, for example, you wanted a variable, you wouldn't re-make the variable every time you wanted to use it. Functions are essentially variables, so the same logic applies.

function onTouched(hit)
game.Players.LocalPlayer.Character.Humanoid.Sit = true
end

game.Workspace.SlideSit.Touched:connect(onTouched)
game.Workspace.SlideSitTwo.Touched:connect(onTouched)
game.Workspace.SlideSitThree.Touched:connect(onTouched)
Report Abuse
coolfun101 is not online. coolfun101
Joined: 25 Jul 2011
Total Posts: 652
21 Dec 2014 04:01 PM
>:omg you can double define a function >:O i never knew that THANK YOU SO MUCH XD

this is definitely a very helpful piece of coding info
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
21 Dec 2014 04:01 PM
(Hint hint)
Stick this at the top of my script, before the function Iter bit

function somefunction(hit)
game.Players.LocalPlayer.Character.Humanoid.Sit = true
end
Report Abuse
coolfun101 is not online. coolfun101
Joined: 25 Jul 2011
Total Posts: 652
21 Dec 2014 04:12 PM
@elun how am i a moron O.o

i am not very experienced at scripting and i am still trying to learn

Logic said if i can not have it work with the same name then simple redo it with a different name each time ..... how is that stupid ..........

it is not my fault for being new O.o I spent most of my time building anyways I very highly request builder
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
21 Dec 2014 04:14 PM
You're a moron because you learn what instead of why. You do stuff because it works, not because you know why or how it works.
Report Abuse
coolfun101 is not online. coolfun101
Joined: 25 Jul 2011
Total Posts: 652
21 Dec 2014 04:20 PM
I do know how what I did works O.o

I made a function
I told it what to do
i ended it
and then i defined it O.o

I may not know all the rules and limitations in scripting like that you can double define a function but i am learning and trying how is that stupid...

If you sit here calling people morons they will give up and never learn
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
21 Dec 2014 04:22 PM
No no no you connected an event.
Where you made that function? That's defining.
Report Abuse
coolfun101 is not online. coolfun101
Joined: 25 Jul 2011
Total Posts: 652
21 Dec 2014 04:26 PM
... knowing that is called an event and not a function does not help me understand how it works
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
21 Dec 2014 04:28 PM
How about you google it so that you understand how it works.
I'm annoyed because you somehow managed to leave somefunction as somefunction, and then question why it broke.
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
21 Dec 2014 04:32 PM
"scription"

lol

i will now use this term
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