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

Client to Client connection, simple message doesnt work?

Asked by 5 years ago

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)
0
If you have a server script that picks up that :FireServer() it would help to see that too LukeSmasher 619 — 5y
0
I dont. Paintertable 171 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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.

Ad

Answer this question