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

Can someone troubleshoot my GUI textbutton?

Asked by 10 years ago

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

Log in to vote
0
Answered by
MrNicNac 855 Moderation Voter
10 years ago
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

0
woops, I forgot to paste the updated script. Namey was what "theplayer" is above, I just forgot to change it. Tempestatem 884 — 10y
Ad

Answer this question