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

Client to Client connection, simple message doesnt work?

So I got my own House buying system where u can buy houses and enter them. Now I want to do it like that players who doesnt own the house can "ring the bell". If they do that a GUI will appear to the player who owns the house.

How can I do that? I tried it with the official and tried to come around it a bit but nothing worked

-- LocalScript
 
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
 
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local messageScreen = playerGui:WaitForChild("MessageScreen")
local recipientInput = messageScreen:WaitForChild("RecipientInput")
local sendButton = messageScreen:WaitForChild("SendButton")
local messageLabel = messageScreen:WaitForChild("MessageLabel")
 
local sendMessageEvent = ReplicatedStorage:WaitForChild("SendMessageEvent")
 
local function onSendButtonClicked()
	local recipientName = recipientInput.Text
	local recipient = Players:FindFirstChild(recipientName)
	if recipient then
		sendMessageEvent:FireServer(recipient)
	end
end
 
local function onMessageReceived(sender)
	messageLabel.Text = sender.Name .. " says hello!"
	messageLabel.Visible = true
	wait(3)
	messageLabel.Visible = false
end
 
sendButton.MouseButton1Click:Connect(onSendButtonClicked)
sendMessageEvent.OnClientEvent:Connect(onMessageReceived)

2 comments

0

If you have a server script that picks up that :FireServer() it would help to see that too

0

I dont.

1 answer

✓ Accepted answer

When the button is clicked have the localscript fire a remote event then have a server script that checks if the event was fired and have the server be the one that creates and puts the gui on the house owners screen, just make the server set the guis parent to the house owners PlayerGui.

a client cannot put guis on another clients screen on Roblox, this would be a major issue if you could. If this were possible exploiters would be able to put any gui on anyone's screen which would be very bad.

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