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 » Scripters
Home Search
 

Re: How would I do this?

Previous Thread :: Next Thread 
DrGigaByte is not online. DrGigaByte
Joined: 02 Mar 2014
Total Posts: 76
18 Jul 2017 11:12 PM
I'm looking to make a way for janitors in my game to check the PH level of a pool (I'm new to scripting) and first off: would I use a NumberValue for it?

This is the little script I have:
brick = script.Parent
guiText = game.StarterGui.ScreenGui.Frame.TextBox.Text
brick.Touched:connect(function(part)
if script.Parent.Parent.Parent.TeamColor == BrickColor.new("White") then
guiText = script.Parent.PHLevel
end
end)
Report Abuse
VilgO is not online. VilgO
Joined: 15 Feb 2011
Total Posts: 518
18 Jul 2017 11:53 PM
Replace "script.Parent ... .Parent" with variables, so that it's easier to read the script, not to mention the tiny performance gain.
Report Abuse
VilgO is not online. VilgO
Joined: 15 Feb 2011
Total Posts: 518
18 Jul 2017 11:54 PM
Have you tried? Is there a problem?
Report Abuse
DrGigaByte is not online. DrGigaByte
Joined: 02 Mar 2014
Total Posts: 76
19 Jul 2017 06:56 PM
Yes it gives an error saying: Touched is not a valid member of Workspace.

Report Abuse
Mr_Crunch is not online. Mr_Crunch
Joined: 16 Jul 2016
Total Posts: 275
19 Jul 2017 07:00 PM
make sure your script is within the actual brick they're touching.
Report Abuse
DrGigaByte is not online. DrGigaByte
Joined: 02 Mar 2014
Total Posts: 76
19 Jul 2017 07:00 PM
Fixed that now says:

16:59:49.422 - Workspace.PoolWater.Script:3: attempt to index global 'hit' (a nil value)
Report Abuse
BaiYuni is not online. BaiYuni
Joined: 09 Oct 2009
Total Posts: 2861
19 Jul 2017 07:04 PM
??

Did you copy a different script? Because you might've changed the parameter name...

And why are you changing the gui from StarterGui? If you want it to change the player's GUI you have to use PlayerGui.
Report Abuse
AyeeAndrxw is not online. AyeeAndrxw
Joined: 21 Sep 2015
Total Posts: 291
19 Jul 2017 07:45 PM
You shouldn't be using this

if script.Parent.Parent.Parent.TeamColor == BrickColor.new('White') then

Also, where is your script located


Thanks! AyeeAndrxw
Report Abuse
DrGigaByte is not online. DrGigaByte
Joined: 02 Mar 2014
Total Posts: 76
19 Jul 2017 08:05 PM
brick = script.Parent
localTeam = game.Players.LocalPlayer.Team
phLevel = script.Parent.PHLevel.Value
function onClicked(playerWhoClicked)
if localTeam == "Janitors" then
print("7")
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)


heres my new script no errors, just does nothing
Report Abuse
BaiYuni is not online. BaiYuni
Joined: 09 Oct 2009
Total Posts: 2861
19 Jul 2017 08:09 PM
Make sure it's a script and put this:

brick = script.Parent
phLevel = script.Parent.PHLevel.Value
function onClicked(playerWhoClicked)
if playerWhoClicked.Team == "Janitors" then
print("7")
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
DrGigaByte is not online. DrGigaByte
Joined: 02 Mar 2014
Total Posts: 76
19 Jul 2017 08:12 PM
Tried that, still doesn't print
Report Abuse
BaiYuni is not online. BaiYuni
Joined: 09 Oct 2009
Total Posts: 2861
19 Jul 2017 08:14 PM
brick = script.Parent
phLevel = script.Parent.PHLevel.Value
function onClicked(playerWhoClicked)
if playerWhoClicked.Team == game:GetService("Teams").Janitors then
print("7")
else
print(playerWhoClicked.Team)
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
AyeeAndrxw is not online. AyeeAndrxw
Joined: 21 Sep 2015
Total Posts: 291
19 Jul 2017 08:16 PM
Okay make sure that it is a proper script and it is inside of the brick


local Part = script.Parent
local PHLevel = Part.PHLevel

Part.ClickDetector.MouseButton1Click:Connect(function(player)
if player then
local team = Player.Team
if team == 'Janitors' then
print(7)
end)


Thanks! AyeeAndrxw
Report Abuse
DrGigaByte is not online. DrGigaByte
Joined: 02 Mar 2014
Total Posts: 76
19 Jul 2017 08:16 PM
Perfect, thanks so much!
Report Abuse
pidgey is not online. pidgey
Joined: 16 Jan 2008
Total Posts: 2739
19 Jul 2017 08:16 PM
you cant compare an object with a string value, Player.Team == "Janitors" will always be false. theres a property in Team called Name, compare Team.Name with "Janitors" instead

if playerWhoClicked.Team.Name == "Janitors" then

or if playerWhoClicked.Team == game.Teams.Janitors
Report Abuse
AyeeAndrxw is not online. AyeeAndrxw
Joined: 21 Sep 2015
Total Posts: 291
19 Jul 2017 08:19 PM
You get the idea of what I was doing. Wasn't using studio to do this


Thanks! AyeeAndrxw
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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