Also what is “coroutines” and how do you use them?
'''
event:FireAllClients("Map chosen was"..ChosenMap)
‘’’
I also tried this but the error was Serverscriptservice.Hallo:21attempt to concatenate string with Instance
Pass ChosenMap as an argument and manage the string concatenation on the client
-- // Server
event:FireAllClients(ChosenMap)
-- // Client
event.OnClientEvent:Connect(function(ChosenMap) print("Map chosen was"..ChosenMap) end)
Can you teach me what “coroutines” are?
They are multi-threads, they basically let you run multiple functions in one script completely independent to themselves
Example:
local function x()
end
local function z()
end
x()
z() -- // Will not run until x has finished
coroutine.resume(coroutine.create(x))
coroutine.resume(coroutine.create(z))
or
local cor_x = coroutine.wrap(x)
local cor_z = coroutine.wrap(z)
cor_x()
cor_z()
Ok thanks a lot! Fore some reason this teleport isn’t working
'''
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = workspace.ChosenMap.CFrame.SpawnPlayersToMap.CFrame
end
'''
All the maps have a spawn called “SpawnPlayersToMap”. But the error is “ChosenMap” is not a vaild member of workspace, even though the chosen map is already in workspace.
Show me your workspace,
And trythis:
for _, player in pairs(game.Players:GetChildren()) do
local char = workspace[player]
char.HumanoidRootPart.CFrame = workspace["ChosenMap"].CFrame.SpawnPlayersToMap.CFrame
end
Why the chosen maps CFrame? (30 chars)
Because it was in your original code
Oh that was a mistake I updated it (Look at my post above)
Just change the code to your preference
Wait about your post above on coroutines. So like in your example, does function x run while function y run, if you use a coroutines?
Like I said before, functions will run independently if using coroutines
Just put a string value in replicated storage, and inside your textlabel, put this code:
local text = game.ReplicatedStorage.StringValue
local parent = script.Parent
parent.Text = text.Value
text:GetPropertyChangedSignal("Value"):Connect(function()
parent.Text = text.Value
end)
And inside the main script, just do
local text = game.ReplicatedStorage.StringValue
text.Value = "Your words here"
From there, the textlabel on all the clients’ screens updates every time the stringvalue updates. Remote Events are not always required for scenarios like this
Wait it so updates for new players so that the text is the same with older players text?
Yes. Since this script will be in the StarterGui, for every player that joins, it goes to their PlayerGui, while the string value is already in the replicated storage (it’s just an alternative to your instance of remote events)
So basically every time a serverscript updates the stringvalue, the local script inside all the player’s guis will recognize that, then change their textlabel’s text to what the stringvalue is
Even if I transition to like ex: “Hello!” to “Goodbye!”
Yes, every change you make to the stringvalue replicates to the local script (which changes the textlabel for all players)
You should make it fire like this.
game.Player.PlayerAdded:Connect(function(player)
RemoteEvent:FireClient(player)
end)
However, if you wanted to add any new frames or textlabels to all the players, then you would use a remote event. For example:
Server Script:
local remote = game.ReplicatedStorage.RemoteEvent
local text = game.ReplicatedStorage.StringValue
local roundnum = 1
local pictures = {
"Speed";
"Slow"
}
for i = 10,1,-1 do
text.Value = "Choosing next round in "..i.." seconds."
wait(1)
end
remote:FireAllClients(pictures[roundnum])
roundnum = roundnum + 1
if roundnum > #pictures then
roundnum = 1
end
In the Local Script (Inside the TextLabel):
local player = game.Players.LocalPlayer
local text = game.ReplicatedStorage.StringValue
local remote = game.ReplicatedStorage.RemoteEvent
local pictures = player.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("Folder")
local parent = script.Parent
parent.Text = text.Value
text:GetPropertyChangedSignal("Value"):Connect(function()
parent.Text = text.Value
end)
remote.OnClientEvent:Connect(function(picture)
for _, v in pairs(pictures:GetChildren()) do
if v.Name == picture then
v.Visible = true
else
v.Visible = false
end
end
end)