Answers for "remote events client to server lua"

0

remote events client to server lua

-- 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 "remote events client to server lua"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language