https://gyazo.com/28cee147791a732342f80a8ebe6ce604
there is the link for the picture, the game is a stort game I just want to call a remote event thank you!
https://gyazo.com/28cee147791a732342f80a8ebe6ce604
there is the link for the picture, the game is a stort game I just want to call a remote event thank you!
You can fire remote events to do communication in client - server, server - client and more! For example, lets make a player gui that makes a server side part.
To start, you can put your remote event in ReplicatedStorage.
Add a script to serverscriptservice, that defines what the remote will do when it gets fired.
local Remote = game.ReplicatedStorage.Remote
Remote.OnServerEvent:Connect(function(Player,Color) --You can insert multiple parameters here, keep in mind the first parameter is always the player
local NewPart = Instance.new("Part")
NewPart.Parent = workspace
NewPart.Color = Color
end)
Now that we are done, make a localscript on a button, when pressed it will fire the remote:
script.Parent.MouseButton1Click:Connect(function() --Click event
game.ReplicatedStorage.Remote:FireServer(Color3.fromRGB(255,255,0))
end)
As a result, the player will make a new part visible to all players on the server!
If you want to communicate server to client, you can insert a localscript in StarterPlayerScripts that will define what it will do:
(We will do if the player touches a brick, it will create a text label to it, Note: I already know there are other ways on how to do this,but this is just to test remote events)
game.ReplicatedStorage.Remote.OnClientEvent:Connect(function(Player,Color)
local TL = Instance.new("TextLabel")
TL.Parent = Player:WaitForChild("PlayerGui").ScreenGui
TL.BackgroundColor3 = Color
end)
Now on the brick, instert a server script, to call the function
script.Parent.Touched:Connect(function(Hit)
local Human = Hit.Parent:FindFirstChild("Humanoid")
if Human then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
game.ReplicatedStorage.Remote:FireClient(Player,script.Parent.Color)
end
end)
If you want to make it for all clients, re-write the remote event line and change it to:
game.ReplicatedStorage.Remote:FireAllClients(script.Parent.Color)
Hope it helps!
This discussion is preserved as it was. New answers, comments, and votes are closed.