RobloxVideoRO / PostcardTrigger.server.lua
arnaupq2's picture
Upload 7 files
a7d70cc verified
Raw History Blame Contribute Delete
1.31 kB
-- PostcardTrigger.server.lua
-- Colocar en: ServerScriptService
--
-- Detecta cuando un jugador toca la parte "PanelPostcard" que debe existir
-- directamente en Workspace, y avisa a SU cliente (vía RemoteEvent) para que
-- arranque la reproducción del video a pantalla completa.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Crea (o reutiliza) el RemoteEvent que usamos para avisar al cliente
local remoteEvent = ReplicatedStorage:FindFirstChild("PlayPostcardVideoEvent")
if not remoteEvent then
remoteEvent = Instance.new("RemoteEvent")
remoteEvent.Name = "PlayPostcardVideoEvent"
remoteEvent.Parent = ReplicatedStorage
end
local panel = workspace:WaitForChild("PanelPostcard")
local debounceByPlayer = {}
local function onTouched(hit)
local character = hit.Parent
if not character then
return
end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid then
return
end
local player = Players:GetPlayerFromCharacter(character)
if not player then
return
end
if debounceByPlayer[player.UserId] then
return
end
debounceByPlayer[player.UserId] = true
remoteEvent:FireClient(player)
task.delay(2, function()
debounceByPlayer[player.UserId] = nil
end)
end
panel.Touched:Connect(onTouched)