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?
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