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

how do I make two text labels change something if their the same?

local Player = game:getService("Players").LocalPlayer
while true do
	if game.Player.PlayerGui.Ticket.Entered.Text == script.Parent.Text then
		game.Workspace.Part.Transparency = 0.5
	end
end

This is the script, its supposed to make a part in workspace visibility equal 0.5 when 2 textlabels are the exact same, but it doesnt work. Can someone help me?

4 comments

0

Many people have tried to help me but every way wouldnt work.

0

Is it a server script or local script?

0

local script

0

Have you read my answer? I spent 20 minutes writing an answer not for it to be ignored, so if you could check it out thanks.

2 answers

First, please change while true do to while wait() do. It could crash the server. Second, Player is not a valid member of game, instead of game.Player, I think you were looking for just Player.

Hello! I hope you're having a great day :D

I can see your struggling with properly and efficiently using the TextBox. Instead of using a while true loop, I recommend you use the GetPropertyChangedSignal("Text") what this does is every time text is changed the event fires, this way we use less load on the server and don't ultimately crash it.

Now, I also see a second problem which is you have multiple parts in the workspace you want to change the transparency of, no problem this is easy to fix by using a simple for loop which I'll show in a second.

Here is the code I've updated for you assuming this is a serverscript:

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(plr)
	local textbox = plr.PlayerGui.Ticket.Entered

	textbox:GetPropertyChangedSignal("Text"):Connect(function()
		if text == 'bobman' then
			for i,v in pairs(game.Workspace:GetChildren()) do
				if v.Name == 'Part' then
					v.Transparency = 0.5
				end
			end
		end
	end)
end)

Basically our for loop changes every part with the name "Part" transparency to 0.5, whent he text 'bobman' is entered, which you can of course change.

Hopefully, I helped you today ;D

Thanks for reading,

  • DrShockz

1 comment

0

That didnt work, but thanks for trying!

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