Why isn’t this working?
-
What do you want to achieve? I’d like to find a solution on this.
-
What is the issue? The following scripts aren’t working, idk why.
-
What solutions have you tried so far? I was looking for solutions, but didn’t find any.
Why isn’t this working?
What do you want to achieve? I’d like to find a solution on this.
What is the issue? The following scripts aren’t working, idk why.
What solutions have you tried so far? I was looking for solutions, but didn’t find any.
What’s not working? I need more details? Where is the textbutton script located and what type of script it is?
The loop tries to access all the players guis, but it’s a local script.
So its gotta be a serverscript?
You need to use .OnServerEvent on the server, and :FireServer() on the client.
I think for what you are trying to do, you just need the local players GUI.
So its all gotta be local script if I understand you correct, right?
You want to send a message from server script to every client. Each client will have a copy of the local script, and can the add the message clone to their GUI.
So change the loop to just get the local player GUI.
If I understood correctly?
Yes, its a kinda radio / vocovo thingy.
Ok. So it’s all ok as far as I can see, apart from the for loop, just take it out and get the local player.
game.players.LocalPlayer.playergui etc
So for example it should be
local player = game.Players.LocalPlayer
local example = player.PlayerGui.VocovoUI.Frame.MainFrame.MSGFrame.StatusExample:Clone()
example.Parent = player.PlayerGui.VocovoUI.Frame.MainFrame.MSGFrame
example.MainText.Text = message
Looks ok.
Personally I always use game:GetService, but am on phone so it’s hard typing code properly.
Check the output for errors, and add prints to check variables if you still have a problem.
Alright so from the start I immediately notice something you forgot. When sending a message from client -> server a parameter gets added at the start player, this is whoever send the message. so basically your server script needs to fix:
local messageEvent = game:GetService("ReplicatedStorage"):WaitForChild("MessageEvent")
messageEvent.OnClientEvent:Connect(function(message)
...
end)
So now let’s fix it by adding the player parameter:
local messageEvent = game:GetService("ReplicatedStorage"):WaitForChild("MessageEvent")
messageEvent.OnClientEvent:Connect(function(player, message)
...
end)
Edit: Wait my bad I read it too quickly, this would not work.
Oops my bad. @KJry_s made me realise something, the server script won’t work in a player’s gui. It needs to be in workspace or serverscriptservice.
The client needs to use a remoteevent to send the message to the server to fireallclients to everyone else.
[Edit]
You will need to check/change the paths on your setup but I think this should work.
Local script (parented to the textbox):
local RS = game:GetService("ReplicatedStorage")
local player = game:GetService("Players").LocalPlayer
script.Parent.TextButton.MouseButton1Click:Connect(function()
local message = script.Parent.Text
game.ReplicatedStorage.SendMessage:FireServer(message) --New remoteevent required
end)
RS:WaitForChild("MessageEvent").OnClientEvent:Connect(function(message)
if game.Workspace["D&J | Djcovo"].Core:WaitForChild("Available").Value == true then
local example = player.PlayerGui.VocovoUI.Frame.MainFrame.MSGFrame.StatusExample:Clone()
example.Parent = player.PlayerGui.VocovoUI.Frame.MainFrame.MSGFrame
example.MainText.Text = message
end
end)
Serverscript (parented in serverscript service):
local RS= game:GetService("ReplicatedStorage")
RS.SendMessage.OnServerEvent:Connect(function(player, message)
print("Message received from", player, "stating", message)
RS.MessageEvent:FireAllClients(message)
)
Player doesn’t pass as an argument since you already several ways of getting player in client.
I do not know what you’re on about, but it certainly does.
in what world does player pass as a default argument in onclientevent