Spaces:
Configuration error
Configuration error
File size: 1,311 Bytes
a7d70cc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | -- 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)
|