I'm trying to create a script (I'm new at scripting) and I'm trying to make it so if you're a janitor you can check the ph level of a pool, this is the script I have for it: brick = script.Parent guiText = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextBox.Text localTeam = script.Parent.Parent.Parent.Teams.Janitors phLevel = script.Parent.PHLevel.Value function onClicked(playerWhoClicked) if localTeam == true then print(phLevel) end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
(It's not organized yet because I'm just testing everything)
Your first line is wrong, as I can see an easy error:
brick = script.Parent guiText = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextBox.Text localTeam = script.Parent.Parent.Parent.Teams.Janitors phLevel = script.Parent.PHLevel.Value
This tries to do too much I can't even understand it.
Try this instead [I hope]
local brick = script.Parent.gui brick.Text = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextBox.Text local Team = game.Players.LocalPlayer.Team local phLevel = script.Parent.PHLevel.Value function onClicked() -- no need for a playerWhoClicked argument unless it's on the server. if Team == "Janitor" then -- code to do if the player is on the janitor team. else print("Not on the Janitor team") end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Some info:
Make sure your script is a LocalScript. This is because it's just easier to work with when using Guis. If you use FE, be sure to add some RemoteEvents and then you'll be able to run server things like updating DataStores [for money] and whatnot.
If you need any help, I'm Reece#4504 on Discord.