generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Exit Detection

Previous Thread :: Next Thread 
mattandjeffhardy619 is not online. mattandjeffhardy619
Joined: 21 Jul 2008
Total Posts: 510
11 Apr 2013 08:48 PM
So I made a script so when I enter the game a brick is on the top of my head, but when I leave the brick stays where was last, anyways you would I delete the brick after I leave?

while wait() do
if game.Players:FindFirstChild("mattandjeffhardy619") then
game.Workspace.Part1.Position = CFrame.new(game.Workspace.mattandjeffhardy619.Torso.Position)
* Vector3.new(0, 8, 0)
end
end
Report Abuse
mattandjeffhardy619 is not online. mattandjeffhardy619
Joined: 21 Jul 2008
Total Posts: 510
11 Apr 2013 08:56 PM
Sorry, I was writing this fast, *How would I delete the brick after I leave?*
Report Abuse
777MrEpic is not online. 777MrEpic
Joined: 17 Oct 2012
Total Posts: 3998
11 Apr 2013 08:57 PM
Never tried.
Report Abuse
FoggedOut is not online. FoggedOut
Joined: 09 Dec 2011
Total Posts: 3021
11 Apr 2013 08:57 PM
It will take me awhile to figure out becuase I'm new to scripting, but I could figure it out.

BTW, I was wondering what you ment up there. I would have fxied for you, but I would have fixed it wrong; I bet anyways I would. xD
Report Abuse
dnic1997 is not online. dnic1997
Joined: 08 May 2010
Total Posts: 309
11 Apr 2013 08:59 PM
Use it the same way as a Data Persistence:

game.Players.PlayerLeaving:connect(function(player)
pcall(function() brick:remove() end)
end)

It's something like that, I can't remember it fully.
Report Abuse
UnBuild is not online. UnBuild
Joined: 22 Mar 2013
Total Posts: 3233
11 Apr 2013 09:00 PM
Parent the part to the lighting when you leave.
Report Abuse
mattandjeffhardy619 is not online. mattandjeffhardy619
Joined: 21 Jul 2008
Total Posts: 510
11 Apr 2013 09:05 PM
@ UnBuild, that's what I'm asking how do I make it detect when I'm leaving?
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
11 Apr 2013 09:07 PM
game.Players.PlayerRemoving:connect(function()
--stuff
end)

like that? o-o
Report Abuse
UnBuild is not online. UnBuild
Joined: 22 Mar 2013
Total Posts: 3233
11 Apr 2013 09:10 PM
One way, not the best, but


if Game.Players:FindFirstChild("YourName") == nil then
--Stuff
end
Report Abuse
mattandjeffhardy619 is not online. mattandjeffhardy619
Joined: 21 Jul 2008
Total Posts: 510
11 Apr 2013 09:39 PM
It's not working 100%, I fell like I'm almost there but not quiet, here's what I got

local Part = game.Lighting.Part1
local PartCopy = Part:Clone()

while wait() do
if game.Players:FindFirstChild("Player1") then
PartCopy.Parent = Workspace
game.Workspace.Part1.Position = CFrame.new(game.Workspace.Player1.Torso.Position)
* Vector3.new(0, 8, 0)
elseif game.Players:FindFirstChild("Player1") == nil then
game.Workspace:FindFirstChild("Part1"):remove()
break
end
end
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
11 Apr 2013 09:48 PM

game.Players.PlayerAdded:connect(function(player)
wait()
local brick=Instance.new("Part",workspace)
brick.CFrame = player.Character.Head.CFrame
game.Players.PlayerRemoving:connect(function(left)
if player.Name==left.Name then
brick:Destroy()
end
end)

end)

--try this. Idk if it works though xP
Report Abuse
dog456pop248 is not online. dog456pop248
Joined: 24 Aug 2008
Total Posts: 3977
11 Apr 2013 09:49 PM
I would us :PlayerRemoving
Report Abuse
nuke009 is not online. nuke009
Joined: 22 Nov 2009
Total Posts: 1930
12 Apr 2013 02:26 AM
Use PlayerRemoving, it fires straight after someone leaves.
Report Abuse
UnBuild is not online. UnBuild
Joined: 22 Mar 2013
Total Posts: 3233
12 Apr 2013 10:42 AM
Because of this

while wait() do
if game.Players:FindFirstChild("mattandjeffhardy619") then
game.Workspace.Part1.Position = CFrame.new(game.Workspace.mattandjeffhardy619.Torso.Position)
* Vector3.new(0, 8, 0)
end
end

I just kinda assumed he didn't know how to use PlayerRemoving
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image