kell1300
|
  |
| Joined: 01 Jan 2009 |
| Total Posts: 66 |
|
|
| 31 Mar 2016 11:28 PM |
I made a script to insert a click detector in a part for my game. When you click on that part, it shows you my shop Gui. The script works just fine when I first join, but when I die or reset, the Gui won't show back up. I've been trying to fix this for going 4 hours, and I still can't find the problem.
Here is the code:
clickDetector = Instance.new("ClickDetector") clickDetector.Parent = game.Workspace.Robloxian.Head clickDetector = true
clickDetector.MouseClick:connect(function(hit) script.Parent.Parent.Character.Humanoid.WalkSpeed = 0 script.Parent.Parent.PlayerGui.Shop.Background.Visible = true end
|
|
|
| Report Abuse |
|
|
|
| 31 Mar 2016 11:30 PM |
"clickDetector = true" You destroyed the reference to the actual ClickDetector when you did that. |
|
|
| Report Abuse |
|
|
RPG_Dev
|
  |
| Joined: 19 Nov 2011 |
| Total Posts: 419 |
|
|
| 31 Mar 2016 11:30 PM |
if the script is in the workspace its because it only runs once
|
|
|
| Report Abuse |
|
|
RPG_Dev
|
  |
| Joined: 19 Nov 2011 |
| Total Posts: 419 |
|
|
| 31 Mar 2016 11:31 PM |
woops nvm read it wrong :C
|
|
|
| Report Abuse |
|
|
Darkenus
|
  |
| Joined: 17 Jul 2014 |
| Total Posts: 1997 |
|
|
| 31 Mar 2016 11:32 PM |
Okay, so I have A LOT of questions.
Starting with:
"clickDetector = true"
1. what exactly is that supposed to be?
2. secondly, you are inserting a clickdetector everytime the player resets? (because guis reset everytime character is respawned)
3. is the shop gui in startergui? or is it added everytime a player joins?
4. what kind of script is this? (local/normal) |
|
|
| Report Abuse |
|
|
kell1300
|
  |
| Joined: 01 Jan 2009 |
| Total Posts: 66 |
|
|
| 31 Mar 2016 11:35 PM |
@Darkenus
1. I forgot to delete that from something I tried earlier
2. I think believe so
3. It's in my starterGui
4. Local
|
|
|
| Report Abuse |
|
|
2013henry
|
  |
| Joined: 09 Apr 2013 |
| Total Posts: 39768 |
|
|
| 31 Mar 2016 11:36 PM |
| Gotta script, script, script everyday! I use Lua, you use Java! Trolololoololol! |
|
|
| Report Abuse |
|
|
Darkenus
|
  |
| Joined: 17 Jul 2014 |
| Total Posts: 1997 |
|
|
| 31 Mar 2016 11:44 PM |
Try this:
local parent = game.Workspace:WaitForChild("Robloxian"):WaitForChild("Head") local clickDetector = parent:FindFirstChild("ClickDetector")
if not clickDetector then clickDetector = Instance.new("ClickDetector", parent) end
clickDetector.MouseClick:connect(function(hit) script.Parent.Parent.Character.Humanoid.WalkSpeed = 0 script.Parent.Parent.PlayerGui.Shop.Background.Visible = true end) |
|
|
| Report Abuse |
|
|
kell1300
|
  |
| Joined: 01 Jan 2009 |
| Total Posts: 66 |
|
|
| 31 Mar 2016 11:47 PM |
@Darkenus It worked! Thanks for the help!
|
|
|
| Report Abuse |
|
|