-
What do you want to achieve?
I want to make a platform where if you stand on it you get added to a ready to leave list. -
What is the issue?
The current method I use to detect if a player has entered the ready platform is really bad (im using .Touched and .TouchEnded), I know I shouldn’t be using Touch events for this, but I have no idea what else to use. -
What solutions have you tried so far?
I have tried using more collision checks, but nothing worked, not sure what to search on google to find solutions.
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Parent:FindFirstChildOfClass("Humanoid") then
local char = hit.Parent.Parent -- makes a var for the character
if char then
local plr = game.Players:GetPlayerFromCharacter(char) -- makes a var for the player kinda useless
if plr and not table.find(playersLeaving, plr) then
table.insert(playersLeaving, plr)
local newTemp = temp:Clone()
newTemp.Name = plr.Name
newTemp.username.Text = plr.Name
if plrPfps[plr.Name] == nil then
local content, isReady = game.Players:GetUserThumbnailAsync(plr.UserId, thumbType, thumbSize)
newTemp.Pfp.Image = content
plrPfps[plr.Name] = content
else
newTemp.Pfp.Image = plrPfps[plr.Name]
end
newTemp.Parent = GUI.SurfaceGui.Frame.ScrollingFrame
end
end
end
end)
script.Parent.TouchEnded:Connect(function(hit)
if hit.Parent.Parent:FindFirstChildOfClass("Humanoid") then
local char = hit.Parent.Parent -- makes a var for the character
if char then
local plr = game.Players:GetPlayerFromCharacter(char) -- makes a var for the player kinda useless
if plr and table.find(playersLeaving, plr) ~= nil then
table.remove(playersLeaving, table.find(playersLeaving, plr))
local gui = GUI.SurfaceGui.Frame.ScrollingFrame:FindFirstChild(plr.Name)
if gui then gui:Destroy() end
end
end
end
end)
(The almost transparent, big, gray block is the parent of the script)