I’m in the need of some help. The issue is, I’m trying to make it so if a ClickDetector isn’t clicked after a certain amount of time (When the player joins) something will happen like being kicked or another thing. Basically I’m trying to have something happen if a ClickDetector isn’t clicked in a certain amount of time.
You could make it where once you have a reason to start the timer you can put a value or something that changes if clicked, and once you have that the script checks if the value has been changed.
I’m fairly new to scripting so there’s probably a better way.
local Game = game
local Workspace = workspace
local Players = Game:GetService("Players")
local RunService = Game:GetService("RunService")
local Part = Workspace.Part
local ClickDetector = Part.ClickDetector
local Table = {}
local Timer = 90 --ClickDetector needs to be clicked within 90 seconds of joining.
local function OnMouseClick(Player)
Table[Player] = nil
end
local function OnPlayerAdded(Player)
Table[Player] = os.time()
end
local function OnPlayerRemoving(Player)
Table[Player] = nil
end
local function OnHeartbeat()
local Current = os.time()
for Player, Time in pairs(Table) do
if (Current - Time) < Timer then continue end
Player:Kick("Too slow!")
end
end
ClickDetector.MouseClick:Connect(OnMouseClick)
Players.PlayerAdded:Connect(OnPlayerAdded)
Players.PlayerRemoving:Connect(OnPlayerRemoving)
RunService.Heartbeat:Connect(OnHeartbeat)