Remote Events

0

  • Lets you do stuff from the client to the server so everyone sees it
  • Because of filteringEnabled if you delete a part from localScript only you see
  • RemoteEvent is a one-way communication (vs two-way for a RemoteFunction)
Step 1: Create ReplicatedStorage Event
  • Add RemoteEvent and call it DeleteBomb
Step 2: Create LocalScript
StarterPlayer/StarterPlayerScripts/LocalScript
local RS = game:GetService("ReplicatedStorage")
local DeleteBomb = RS:WaitForChild("DeleteBomb")
local UIS = game:GetService("UserInputService")

function doIt(input, gameProcessedEvent)
    if input.KeyCode == Enum.KeyCode.R then
        print("R pressed!")
        local Bomb = game.Workspace:FindFirstChild("Bomb")
        if Bomb then
            DeleteBomb:FireServer(Bomb)
        end
    end
end

UIS.InputBegan:Connect(doIt)
Step 3: Create a server script
ServerScriptService/Script
local RS = game:GetService("ReplicatedStorage")
local DeleteBomb = RS:WaitForChild("DeleteBomb")

local function doIt(player, part)
    part:Destroy()
end

DeleteBomb.OnServerEvent:Connect(doIt)

https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

https://www.youtube.com/watch?v=GwhPXyYKkwU&list=PLhieaQmOk7nIoGnFoACf33M3o0BOqB38a&index=9

  • 0 posts
  • 0 subtopics
  • 18 days ago by vince