Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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)

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. Bluemonkey132 194 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Your first line is wrong, as I can see an easy error:

1brick = 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]

01local brick = script.Parent.gui
02brick.Text = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextBox.Text
03 
04local Team = game.Players.LocalPlayer.Team
05local phLevel = script.Parent.PHLevel.Value
06 
07function onClicked() -- no need for a playerWhoClicked argument unless it's on the server.
08if Team == "Janitor" then
09    -- code to do if the player is on the janitor team.
10else
11    print("Not on the Janitor team")
12end
13script.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.

Ad

Answer this question