Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My script is not working, I'm trying to setup a script with a number value, why is it not working?

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)

1 comment

0

What is 'script.Parent.Parent.Parent.Teams.Janitors'? Is it an actual team instance? If so you need to check if it's TeamColor is the same as the TeamColor of the player.

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.