Hi!
Basically What I Need
I need help with the TouchEnded thing in ROBLOX Studio, I am Making a Game Teleporter ** which makes it so when there are 10 people touching a Brick it Teleports all the Players who are touching the brick into a game** which has 10 Players MAX for the Game
This is the Current Layout for the Script (I am a very new DEV so im not really fully into LUA Coding, Im also learning LUA but if you could help me out i would Appreciate it loads)
-- This is a RemoteEvent that Clones the GUI into the Players PlayerGUI
game.Workspace.Events.TouchedEvent.OnServerEvent:Connect(function()
local GUI = script.JoinedCount
script.Parent.Touched:connect(function(hit)
GUI.Players.LocalScript.Disabled = false
if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then
local plr = game.Players[hit.Parent.Name]
if plr:FindFirstChild("PlayerGui") and not plr.PlayerGui:FindFirstChild(GUI.Name) then
GUI:Clone().Parent = plr.PlayerGui
print("Gave Player "..hit.Parent.Name.." GUI")
end
end
end)
end)
--Touching Brick (THIS PART WORKS)
local touching = {}
local part = script.Parent
part.Touched:connect(function(hit)
local player = game.Players:playerFromCharacter(hit.Parent)
if not player then return end
game.Workspace.Events.TouchedEvent:FireServer()
table.insert(touching, player)
end)
-- THIS IS THE PART I NEED HELP WITH (RemoteEvent Would help lots)
part.TouchEnded:connect(function(hit,player1)
local player = game.Players:playerFromCharacter(hit.Parent)
if not player then return end
-- I NEED THE CODE WHICH REMOVES THE GUI ABOVE WHEN THE TOUCHENDED -- FUNCTION IS USED
for index, touch in pairs(touching) do
if player == touch then
table.remove(touching, index)
end
end
end)

1 comment
to remove something write "part:Destroy()" and change "part" to whatever you need to get rid of.