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

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

Asked by 4 years ago
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?

0
Many people have tried to help me but every way wouldnt work. proudCdthekitten 22 — 4y
0
Is it a server script or local script? aadenboy 17 — 4y
0
local script proudCdthekitten 22 — 4y
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. DrShockz 233 — 4y

2 answers

Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago

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.

Ad
Log in to vote
0
Answered by
DrShockz 233 Moderation Voter
4 years ago
Edited 4 years ago

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

0
That didnt work, but thanks for trying! proudCdthekitten 22 — 4y

Answer this question