-- Server Script placed in ServerScriptService -- Services local Players =…
- User
-- Server Script placed in ServerScriptService
-- Services local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- References to the required parts local detector = workspace:FindFirstChild("detector") local tp = workspace:FindFirstChild("tp")
-- Ensure the parts exist if not detector then warn("Detector part not found in Workspace.") return end
if not tp then warn("Teleport part (tp) not found in Workspace.") return end
-- RemoteEvent to communicate with the client local RemoteEvent = ReplicatedStorage:FindFirstChild("ChatRemoteEvent") if not RemoteEvent then RemoteEvent = Instance.new("RemoteEvent") RemoteEvent.Name = "ChatRemoteEvent" RemoteEvent.Parent = ReplicatedStorage end
-- Ensure the StartNightEvent exists local StartNightEvent = ReplicatedStorage:FindFirstChild("StartNightEvent") if not StartNightEvent then StartNightEvent = Instance.new("RemoteEvent") StartNightEvent.Name = "StartNightEvent" StartNightEvent.Parent = ReplicatedStorage end
-- Variable to prevent multiple triggers local touchDebounce = false
-- Function to handle the touch event local function onTouched(otherPart) if touchDebounce then return end touchDebounce = true
local character = otherPart.Parent local humanoid = character:FindFirstChildOfClass("Humanoid") if humanoid then local player = Players:GetPlayerFromCharacter(character) if player then -- Teleport the player's HumanoidRootPart to the "tp" part local hrp = character:FindFirstChild("HumanoidRootPart") if hrp then hrp.CFrame = tp.CFrame else warn("HumanoidRootPart not found for character.") touchDebounce = false return end -- Set the player's walk speed to 0 humanoid.WalkSpeed = 0 -- Fire the RemoteEvent to the player's client to send the chat messages RemoteEvent:FireClient(player, "Welp. this is it. My new job.") -- Wait for 3 seconds task.wait(3) -- Send the second message RemoteEvent:FireClient(player, "I mean. how hard can it be? I just only have to watch the place for only 4 nights anyway!") -- Wait another 3 seconds task.wait(3) -- Fire the StartNightEvent to the player StartNightEvent:FireClient(player) -- Reset walk speed humanoid.WalkSpeed = 16 -- Reset to default walk speed -- Allow the touch event to trigger again after a delay (if needed) task.wait(1) end end touchDebounce = falseend
-- Connect the touch event to the detector part detector.Touched:Connect(onTouched) -- LocalScript placed in StarterPlayerScripts or inside the ScreenGui
-- Services local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer local playerGui = player:WaitForChild("PlayerGui")
-- Wait for RemoteEvents local ChatRemoteEvent = ReplicatedStorage:WaitForChild("ChatRemoteEvent") local StartNightEvent = ReplicatedStorage:WaitForChild("StartNightEvent")
- Assistant