I’m trying to create a 1v1 system utilizing RemteFunctions
as a way to communicate if the player being invited has declined or accepted, however, upon invoking, it does yield and returns nil.
local Response = ReplicatedStorage.Assets.Events.Invite:InvokeClient(Invitee, Player.Name:upper())
print(Response)
--
Important.Services.ReplicatedStorage.Assets.Events.Invite.OnClientInvoke = function(Player:string?)
print(Player)
local UI = Important.Services.ReplicatedStorage.Assets.Frame:Clone()
UI.TextLabel.Text = "["..Player.."] WANTS TO BATTLE!"
UI.Name = "holder"
UI.Parent = Important.Services.Players.LocalPlayer.PlayerGui.MainUI
Important.Services.TweenSerice:Create(UI, TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.InOut), {Position = UDim2.new(0.305, 0,0.778, 0)}):Play()
UI.Accept.MouseButton1Down:Once(function()
Important.Services.TweenSerice:Create(UI, TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.InOut), {Position = UDim2.new(0.305, 0,1, 0)}):Play()
task.delay(0.5,function()
UI:Destroy()
UI = nil
end)
return true
end)
end)
The UI is created but it returns nil and immediately.
3 Likes
You forgot to wait until button gets clicked.
local Response = ReplicatedStorage.Assets.Events.Invite:InvokeClient(Invitee, Player.Name:upper())
print(Response)
--
Important.Services.ReplicatedStorage.Assets.Events.Invite.OnClientInvoke = function(Player:string?)
print(Player)
local UI = Important.Services.ReplicatedStorage.Assets.Frame:Clone()
UI.TextLabel.Text = "["..Player.."] WANTS TO BATTLE!"
UI.Name = "holder"
UI.Parent = Important.Services.Players.LocalPlayer.PlayerGui.MainUI
Important.Services.TweenSerice:Create(UI, TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.InOut), {Position = UDim2.new(0.305, 0,0.778, 0)}):Play()
local buttonClicked = false; -- buttonClicked local variable
UI.Accept.MouseButton1Down:Once(function()
Important.Services.TweenSerice:Create(UI, TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.InOut), {Position = UDim2.new(0.305, 0,1, 0)}):Play()
task.delay(0.5,function()
UI:Destroy()
UI = nil
end)
--return true
buttonClicked = true; set variable that button is clicked.
end)
repeat task.wait()until buttonClicked; -- wait for button to be clicked
return true;
end)
1 Like
Seems like that fixed it, but why? I thought remote functions hang forever until something is returned?
1 Like
yeah I know but you returned nothing.
system
(system)
Closed
December 1, 2023, 4:44pm
#5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.