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: function hit() help.

Previous Thread :: Next Thread 
XhymbbQd6 is not online. XhymbbQd6
Joined: 22 Jul 2011
Total Posts: 1468
09 Aug 2012 06:14 PM
hiter = hit.Parent.LocalPlayer

function hit()
hiter.PlayerGui.TTSB.MainFrame.Visible = true
end



when a player touches it, it shows a Gui. whats wrong with this?
Report Abuse
Brofessions is not online. Brofessions
Joined: 30 Jul 2012
Total Posts: 214
09 Aug 2012 06:16 PM
There are many things wrong with this, but it seems like you got your pathing correct.

function hit(part)
if game.Players:GetPlayerFromCharacter(part.Parent) then -- checks if it's a Player
local p = game.Players:GetPlayerFromCharacter(part.Parent)
[.PlayerGui.TTSB.MainFrame.Visible = true
end
end

script.Parent.Touched:connect(hit)
Report Abuse
chickenman158 is not online. chickenman158
Joined: 18 Jan 2011
Total Posts: 915
09 Aug 2012 06:17 PM
That there is no actually way to determine if it has been hit or not.
That is your problem :P.
Report Abuse
XhymbbQd6 is not online. XhymbbQd6
Joined: 22 Jul 2011
Total Posts: 1468
09 Aug 2012 06:26 PM
I forgot the connection line xD god thats a rookie mistake. but thank you... I am new to going into the Players file.
Report Abuse
djdjdj is not online. djdjdj
Joined: 21 Mar 2008
Total Posts: 10
09 Aug 2012 06:31 PM
function hit(hiter)
Report Abuse
iAdobe is not online. iAdobe
Joined: 22 May 2011
Total Posts: 367
09 Aug 2012 06:43 PM


hiter = hit.Parent.LocalPlayer -- Won't work, defined before the function? Not Sure, and it's not a valid way to find the player, anyways! this would only work on localscript!

function hit()
hiter.PlayerGui.TTSB.MainFrame.Visible = true -- You're getting there.
end







function Touched(Hit) -- Hit is the argument needed for the touched connection line.
if Hit.Parent:FindFirstChild("Humanoid") then -- checks if it's a humanoid
local Player = Game.Players:FindFirstChild(Hit.Parent.Name) -- finds the name
if Player then -- makes sure it's there
if not Player.PlayerGui.TTSB.MainFrame.Visible then -- Makees sure Gui isn't visible already
Player.PlayerGui.TTSB.MainFrame.Visible = true
end
end
end
end

Game.Workspace.Part.Touched:connect(Touched)

Now there's a lot of ways to do this, I just perfer doing it like that.
Report Abuse
XhymbbQd6 is not online. XhymbbQd6
Joined: 22 Jul 2011
Total Posts: 1468
09 Aug 2012 06:54 PM
Wait.. what? Sorry I didn't understand it.
Report Abuse
iAdobe is not online. iAdobe
Joined: 22 May 2011
Total Posts: 367
09 Aug 2012 06:59 PM
I suck at explaining qq
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