Answers for "remote events roblox"

5

remoteevent roblox

--Server => Client
remoteEvent:FireAllClients() --Server Script
remoteEvent:FireClient(player) --Server Script
remoteEvent.OnClientEvent:Connect() --Local Script

--Client => Server
remoteEvent:FireServer() --Local Script
remoteEvent.OnServerEvent:Connect() -- Server Script
Posted by: Guest on November-19-2020
0

remote events roblox

-- Example on creating a part. Using Remote Events
-- Client - Server.

-- (Local Script) Fire Remote Event

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
     
    local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEventTest")
     
    -- Fire the remote event
    remoteEvent:FireServer()
    
    -- Include additional data when firing the event
    -- Like passing Color and Position to Server
    
    -- remoteEvent:FireServer(BrickColor.Red(), Vector3.new(0, 25, 0)) --

-- (Script) Create Part on Server
	local ReplicatedStorage = game:GetService("ReplicatedStorage")
     
    --Get removeEvent from the ReplicatedStorage
    local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEventTest")
     
    -- Create a new part
    local function onCreatePart(player, partColor, partPos)
    	print(player.Name .. " fired the remote event")
    	local newPart = Instance.new("Part")
        
        -- Use attributes you passed on
    	newPart.BrickColor = partColor
    	newPart.Position = partPos
    	newPart.Parent = workspace
    end
     
    -- Call "onCreatePart()" when the client fires the remote event
    remoteEvent.OnServerEvent:Connect(onCreatePart)
Posted by: Guest on September-15-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language