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
 

Need help!

Previous Thread :: Next Thread 
Firestormx11 is not online. Firestormx11
Joined: 19 Nov 2012
Total Posts: 266
02 Apr 2014 04:47 AM
How do I make a script that does something when the Player touches a certain object?

Example; When the player touches a specific object/part. A script makes the ScreenGui text to change.

Please make the Script re usable or something.
THX!
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
02 Apr 2014 04:50 AM
local part=workspace.Part --Show the script which part will activate the action

local function action(hitBy)--define what happens when 'part' is touched
print(tostring(part).." was hit by "..tostring(hitBy).."!")
end

part.Touched:connect(action)--Connect the 'action' function to the 'Touched' event
Report Abuse
Firestormx11 is not online. Firestormx11
Joined: 19 Nov 2012
Total Posts: 266
03 Apr 2014 03:36 AM
It doesn't work. This is the script you gave me.
local part=workspace.Part1
local function action(hitBy)Game.Workspace.StarterGui.Subtitles.Text="Testing Done"
print(tostring(part).." was hit by"..tostring(hitBy).."!")
end


part.Touched:connect(action)

When I touched the brick, the output window printed : "Disconnected event because of exception"
And the GUI's text didn't change.
Report Abuse
Firestormx11 is not online. Firestormx11
Joined: 19 Nov 2012
Total Posts: 266
03 Apr 2014 03:39 AM
I noticed an error and I edited the script but it still doesn't work! Still says Disconnected event because of exception.

local part=workspace.Part1
local function action(hitBy)Game.Workspace.StarterGui.Subtitles.Frame.Textbox.Text="Testing Done"
print(tostring(part).." was hit by"..tostring(hitBy).."!")
end


part.Touched:connect(action)
Report Abuse
KiwiTronik is not online. KiwiTronik
Joined: 18 Feb 2010
Total Posts: 3221
03 Apr 2014 05:05 AM
Game.StarterGui?
Report Abuse
blockhawkdown is not online. blockhawkdown
Joined: 29 Mar 2014
Total Posts: 38
03 Apr 2014 05:40 AM
Put the script below in StarterGui.

local item = Workspace.TouchedPart
local player = script.Parent.Parent

function touched(hit)
player.PlayerGui.Subtitles.Frame.TextBox.Text = "Testing Done"
end

item.Touched:connect(touched)
Report Abuse
Firestormx11 is not online. Firestormx11
Joined: 19 Nov 2012
Total Posts: 266
04 Apr 2014 08:52 AM
Can you please explain the script to me and make it re usable? thanks.



~Only fools jump in where the angels fear to tread~
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