“Acara Jarak Jauh Roblox” Kode Jawaban

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
ClasWasHere

Acara Jarak Jauh 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)
Adventurous Ant

Jawaban yang mirip dengan “Acara Jarak Jauh Roblox”

Pertanyaan yang mirip dengan “Acara Jarak Jauh Roblox”

Lebih banyak jawaban terkait untuk “Acara Jarak Jauh Roblox” di TypeScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya