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 » Scripting Helpers
Home Search
 

Re: How do I make an onTouch script?

Previous Thread :: Next Thread 
sidekick601 is not online. sidekick601
Joined: 27 Feb 2012
Total Posts: 8734
08 Jul 2013 04:46 PM
I know how to make it, but when someone touches a brick, it shows a message with their name on it. How do I make it so it shows their name on it?
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
08 Jul 2013 04:46 PM
By using the Part.Touched event.
Report Abuse
sidekick601 is not online. sidekick601
Joined: 27 Feb 2012
Total Posts: 8734
08 Jul 2013 04:47 PM
you clearly didn't read my full post.
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
08 Jul 2013 04:48 PM
First it's a capatilized O and T OnTouched and it's a function what did you write in it?

I might be able to help
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
08 Jul 2013 04:49 PM
With the Part.Touched event. And Humanoids. Probably want some waits thrown in there, too. I will not, however, make the script for you. That's for you to do. I will simply tell you what you need, and help if you need it
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
08 Jul 2013 04:50 PM
@thetacah: Function names are meaningless, so long as they are not keywords.
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
08 Jul 2013 04:50 PM
@thetacah

Get out.

kthx
bai
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
08 Jul 2013 04:51 PM
@thetacah It doesn't matter what the function is named. However the event is .Touched

function blueberrywafflesontoast(fingerlickngewd)
print(fingerlickngewd.Name)
end
script.Parent.Touched:connect(blueberrywafflesontoast)
Report Abuse
sidekick601 is not online. sidekick601
Joined: 27 Feb 2012
Total Posts: 8734
08 Jul 2013 04:51 PM
I clearly said, I know how to do an onTouched function. I don't need help on that part. But how do I make it so the script knows which player touched it and what their username is. Try reading. It helps.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
08 Jul 2013 04:54 PM
Players:GetPlayerFromCharacter(Instance Character)

Try reading the wiki. It helps.
Report Abuse
grimm343 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
08 Jul 2013 04:55 PM
The .Touched event gives the function the BasePart that was used to touch it.

script.Parent.Touched:connect(function(hit)
print(hit.Name)
end)

Now, for what you would like, assuming that a Hat wouldn't trigger the Message to show..
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
--create a new Message, Parent it to wherever you would like it.. The plr.StarterGui would only let that Player see it, Workspace would let everybody see it.
--Set the Message's Text to plr.Name
end
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
08 Jul 2013 04:56 PM
Guys I know I ment the event sorry
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
08 Jul 2013 04:56 PM
concatenation of the hit argument

local db = true
script.Parent.Touched:connect(function(hit) --hit is whatever touched the brick
if hit and db and hit.Parent:findFirstChild("Humanoid") then
db = false
m = Instance.new("Message", game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui)
m.Text = "Hello, "..hit.Parent.Name.. "!" --hit would probably print right or left leg. Hit.Parent will
get the player's name.
game:GetService("Debris"):AddItem(m, 3)
wait()
db = true
end
end)

prolly l8 w/e
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
09 Jul 2013 08:04 PM
Notunknown!
My friend!
Report Abuse
IAmReallyAwesome is not online. IAmReallyAwesome
Joined: 05 Mar 2010
Total Posts: 7371
09 Jul 2013 08:10 PM
Please note that everyone will see this message.

working = false
script.Parent.Touched:connect(function(hit)
if working == false then
working = true
m = Instance.new("Message", Workspace)
m.Text = hit.Parent.Name
wait(5) --How long you want to wait
m:Destroy()
working = false
end
end)

If you want only the user who touched the brick to see the message, that would require a custom created model to be put into lighting and cloned into the Player's PlayerGui, so I can't really help you there XD

*Tell me about the rabbits, George*
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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