Meowth552
|
  |
| Joined: 17 Dec 2009 |
| Total Posts: 2181 |
|
|
| 02 Jul 2016 02:47 PM |
My current script.
function onClicked(playerWhoClicked)
----------------------------------------------------------------------------------------------------
-- Lock if _G.locked == false and game.Players.LocalPlayer.UserId == game.CreatorId then _G.locked = true
----------------------------------------------------------------------------------------------------
-- Unlock elseif _G.locked == true and game.Players.LocalPlayer.UserId == game.CreatorId then _G.locked = false
----------------------------------------------------------------------------------------------------
end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
I have tried to make it check for if the LocalPlayer's ID is the same as the Creator, but to no avail. How would I solve this? |
|
|
| Report Abuse |
|
|
Crimsonal
|
  |
| Joined: 23 Apr 2011 |
| Total Posts: 1795 |
|
| |
|
Meowth552
|
  |
| Joined: 17 Dec 2009 |
| Total Posts: 2181 |
|
|
| 02 Jul 2016 02:55 PM |
It did not work.
This is my current script after adding name checks:
function onClicked(playerWhoClicked)
----------------------------------------------------------------------------------------------------
-- Lock if _G.locked == false and game.Players.LocalPlayer.Name == "Meowth552" then _G.locked = true elseif _G.locked == false and game.Players.LocalPlayer.Name ~= "Meowth552" then wait()
----------------------------------------------------------------------------------------------------
-- Unlock if _G.locked == true and game.Players.LocalPlayer.Name == "Meowth552" then _G.locked = false elseif _G.locked == true and game.Players.LocalPlayer.Name ~= "Meowth552" then wait()
----------------------------------------------------------------------------------------------------
end end end
script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
| Report Abuse |
|
|
Crimsonal
|
  |
| Joined: 23 Apr 2011 |
| Total Posts: 1795 |
|
|
| 02 Jul 2016 03:02 PM |
function onClicked(playerWhoClicked)
----------------------------------------------------------------------------------------------------
-- Lock if _G.locked == false and playerWhoClicked.Name == "Meowth552" then _G.locked = true elseif _G.locked == false and playerWhoClicked.Name ~= "Meowth552" then wait()
----------------------------------------------------------------------------------------------------
-- Unlock if _G.locked == true and playerWhoClicked.Name == "Meowth552" then _G.locked = false elseif _G.locked == true andplayerWhoClicked.Name ~= "Meowth552" then wait()
----------------------------------------------------------------------------------------------------
end end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
By the way make sure you're not in test mode because if you are roblox assigns your name to Player or Player1 |
|
|
| Report Abuse |
|
|
Meowth552
|
  |
| Joined: 17 Dec 2009 |
| Total Posts: 2181 |
|
|
| 02 Jul 2016 03:08 PM |
Ah, test mode was the issue.
Thanks for the help! =) |
|
|
| Report Abuse |
|
|
Meowth552
|
  |
| Joined: 17 Dec 2009 |
| Total Posts: 2181 |
|
|
| 02 Jul 2016 03:30 PM |
Seems it is still not working.
function onClicked(playerWhoClicked)
----------------------------------------------------------------------------------------------------
-- Lock if _G.locked == false and playerWhoClicked.Name == "Player1" then _G.locked = true elseif _G.locked == false and playerWhoClicked.Name ~= "Player1" then wait()
----------------------------------------------------------------------------------------------------
-- Unlock if _G.locked == true and playerWhoClicked.Name == "Player1" then _G.locked = false elseif _G.locked == true and playerWhoClicked.Name ~= "Player1" then wait()
---------------------------------------------------------------------------------------------------- end end end
script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2016 03:41 PM |
| For someone who keeps their scripts apart for tidyness, your script is organized rather ugly. |
|
|
| Report Abuse |
|
|
Meowth552
|
  |
| Joined: 17 Dec 2009 |
| Total Posts: 2181 |
|
|
| 02 Jul 2016 03:43 PM |
@Above
For someone who keeps whining about how others should do things, your opinions are rather useless. |
|
|
| Report Abuse |
|
|
Meowth552
|
  |
| Joined: 17 Dec 2009 |
| Total Posts: 2181 |
|
|
| 02 Jul 2016 03:43 PM |
| Also, if you have complaints, please do tidy my script up. Thanks! =) |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2016 03:46 PM |
Your original script should look like this:
function onClicked(playerWhoClicked) if _G.locked == false and game.Players.LocalPlayer.UserId == game.CreatorId then _G.locked = true elseif _G.locked == true and game.Players.LocalPlayer.UserId == game.CreatorId then _G.locked = false end end
And you should combine those 2 scripts that you're using _G.locked for because it looks ugly using _G.locked so much :) |
|
|
| Report Abuse |
|
|
Meowth552
|
  |
| Joined: 17 Dec 2009 |
| Total Posts: 2181 |
|
|
| 02 Jul 2016 03:50 PM |
| I can't combine the two scripts because I have no idea how to detect clicks on another part and then implement it into my script. =) |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2016 04:11 PM |
war, chill out he just didn't use your idea. |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2016 04:14 PM |
'I can't combine the two scripts because I have no idea how to detect clicks on another part and then implement it into my script. =)'
Just set up a second MouseClick event on a different part. I'll show you how if you want, it's really simple :)
@Above It wasn't an idea, it was the proper way to do something. I'm trying to help him organize his code so it's more readable. |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2016 04:17 PM |
| sorry, i was in the wrong there |
|
|
| Report Abuse |
|
|