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

Invite system gui not showing in player!?

Asked by 5 years ago
Edited 5 years ago

So I have this invite system where it will invite a player when you type a player's name in a text box and click a button

The problem:

Whenever the function, sendUI() gets executed, the UI will not appear and the script will stop running

(Note: My script is really messy when I pasted it in for some reason. I did indent. The cleanness of the script is not the problem.) Script:

local plr = game.Players.LocalPlayer

local pgui = plr.PlayerGui

local main = pgui:WaitForChild('Main')

local party = main.Party

local event = game:GetService('ReplicatedStorage'):WaitForChild('Invite')

local gui = game:GetService('ReplicatedStorage'):WaitForChild('InviteUI')

print(gui)

print('Script is running!')



function sendUI(plr)

local clone = gui:Clone()

if plr.PlayerGui~= nil then

clone.Parent = plr.PlayerGui

clone.Invitor.Value = plr.Name

end

end





script.Parent.MouseButton1Click:Connect(function()

local box = script.Parent.Parent.InvitePlr

local status = box.Parent.InviteStatus

local playerfound = false

local nextplr

for _, p in pairs(game.Players:GetPlayers()) do

print(p)

if box.Text == p.Name or box.Text == string.lower(p.Name) or box.Text == string.upper(p.Name) then

playerfound= true

nextplr = p

print(nextplr)

break

end

end

print(nextplr)

if playerfound == true and box.Text~=plr.Name and box.Text~=string.lower(plr.Name) and box.Text~= string.upper(plr.Name) then

status.Visible = true

status.Text = 'Invite sent'

sendUI(nextplr)

wait(2)

status.Visible = false

elseif playerfound == false then

status.Visible = true

status.Text = 'Player not found...'

wait(2)

status.Visible = false

elseif box.Text == plr.Name or box.Text == string.upper(plr.Name) or box.Text == string.lower(plr.Name) then

status.Visible = true

status.Text ='You cannot invite your self'

wait(2)

status.Visible = false

end

end)

Answer this question