สอนเขียน Script Victory Point

 




สร้างโมเดลที่มีสองเสา Beam แทนผ้าใบ และแอบมีเซนเซอร์อยู่ที่ฐานโดยซ่อนเอาไว้ (Transparent=1)

ใต้ SensorPart ใส่ Script ตามนี้ครับ

local SensorPart = script.Parent

local Beam = SensorPart.Parent.Beam
local ParticleEmitter1 = SensorPart.Parent.LeftPart.ParticleEmitter
local ParticleEmitter2 = SensorPart.Parent.RightPart.ParticleEmitter

local sound = SensorPart:FindFirstChild("Gun Shot")

local win = false
SensorPart.Touched:Connect(function(otherPart)
if win then return end
if otherPart.Parent:FindFirstChild("Humanoid") then
win = true
sound:Play() --เล่นเสียงพลุ
Beam:Destroy() --ปลดแผ่นผ้า
ParticleEmitter1.Enabled = true --ปล่อยพลุ 1
ParticleEmitter2.Enabled = true --ปล่อยพลุ 2
end
end)

ความคิดเห็น