So basically if they are touching a part called 'detector' their username will be shown on a surface UI. If there's multiple it would display it as USER1, USER2
Is this possible and how would you do it?
So basically if they are touching a part called 'detector' their username will be shown on a surface UI. If there's multiple it would display it as USER1, USER2
Is this possible and how would you do it?
Here's a example (i'd recomend use Region3 instead Touch Events)
There's model link if you had some issue MODEL
--Important: Your detection part must be more high than players avatar
local Players = game:GetService("Players")
local touchPart = script.Parent.touchPart -- your detection part
local surfaceGui = script.Parent.surfacePad.SurfaceGui -- your surface gui
local touchingPlayers = {} -- create a table to store players that are touching
touchPart.Touched:Connect(function(obj) -- when the part is touched
if obj.Parent:FindFirstChild("Humanoid") then -- check if who's touched the part has humanoid
if Players:GetPlayerFromCharacter(obj.Parent) then -- check if the object is a player
if not table.find(touchingPlayers, obj.Parent.Name) then -- check if player name isn't already on table
table.insert(touchingPlayers, obj.Parent.Name) --insert player name on table
end
surfaceGui.TextLabel.Text = table.concat(touchingPlayers, ', ') -- concat all strings on the table
end
end
end)
touchPart.TouchEnded:Connect(function(obj) -- when someone has 'untouched' the part
if table.find(touchingPlayers, obj.Parent.Name) then -- check if is in table
table.remove(touchingPlayers, table.find(touchingPlayers, obj.Parent.Name)) -- remove from table
surfaceGui.TextLabel.Text = table.concat(touchingPlayers, ', ') -- update surface text
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
you are amazing tysm!! :)
hey uh theres a glitch, where if the player leaves they are stuck on the board