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

Can someone troubleshoot my GUI textbutton?

I'm not a very good scripter. But basically this is a warning system for a group I am in

Output:

17:22:59.630 - theplayer is not a valid member of Players

17:22:59.631 - Script 'Players.Player1.PlayerGui.HRWarn.Frame.Frame.TextButton.Scr', Line 6

17:22:59.632 - Stack End

17:22:59.633 - Disconnected event because of exception

Script:

script.Parent.MouseButton1Click:connect(function()
plr=script.Parent.Parent.Parent.Parent.Parent.Parent
theplayer = script.Parent.Parent.Name.Text
HR=plr.Name
reason = script.Parent.Parent.Reason.Text
if game.Players.theplayer==nil then
else

theplayer.PlayerGui.Warning.Frame.Visible=true
theplayer.PlayerGui.Warning.Frame.Part1.Text="You have been given a warning by "..HR..", if you continue to break the rules, you may be banned from the event"
theplayer.PlayerGui.Warning.Frame.Part2.Text="Reason for the warning: "..reason
end

end)

1 answer

✓ Accepted answer
if game.Players.namey==nil then

You should be using the ROBLOX method FindFirstChild to check if an instance exists.

if game.Players:FindFirstChild("namey") then

EDIT

Then the fix is:

if not game.Players:FindFirstChild(theplayer) then

1 comment

0

woops, I forgot to paste the updated script. Namey was what "theplayer" is above, I just forgot to change it.

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