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: Player respawning resulting in error...

Previous Thread :: Next Thread 
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
11 Oct 2012 10:18 PM
This is a local script. I don't get anything in output, and I can't figure out what I'm doing wrong. Everything works except the moving of the respawned player to the new position (and the color being somwhat randomized in build, oh well). Can I have some help? The code is kind of messy, I was referring to the wiki more then I probably should have...



s = Instance.new("Smoke")
v = Instance.new("StringValue")
function Equipped()
if script.Parent.Parent.Parent.Parent.ClassName == "Player" then
v.Parent = script.Parent
v.Value = script.Parent.Parent.Parent.Parent.Name

end
end

script.Parent.Parent.Equipped:connect(Equipped)
script.Parent.Parent.Unequipped:connect(Equipped)

function onButton1Down(mouse)
local p = Game.Players.LocalPlayer
local m = p:GetMouse()
script.Parent.Position = Vector3.new(m.Hit)
script.Parent.Parent.Parent = game.Workspace
script.Parent.Anchored = true
script.Parent.CanCollide = true
script.Parent.Parent = game.Workspace
game.Workspace.TacticalInsertion:Remove()
s.Parent = script.Parent
s.Opacity = 0.2
s.RiseVelocity = 1
s.Size = 1
s.Color = Color3.new(0, 128, 0)
end
script.Parent.Parent.Equipped:connect(function(m) m.Button1Down:connect(onButton1Down)end)

-- I think script stops working under this line

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
--Player = game.Players.PlayerAdded
if Character.Name == v.Value then
Player.Torso.CFrame = CFrame.new(script.Parent.Position)
script.Parent:Remove()
end
end)
end)
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
11 Oct 2012 10:30 PM
Well since you have that in a tool it will not work because the tool goes away with the player when they die, also m = p:GetMouse() is uneeded because you already have the mouse from the function.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
11 Oct 2012 10:34 PM
"script.Parent.Parent.Parent = game.Workspace"

I reparent it here, so I don't think that is the problem.
Report Abuse
ArbiterOfDeath is not online. ArbiterOfDeath
Joined: 20 Jun 2011
Total Posts: 1458
11 Oct 2012 10:39 PM
How about this. Local scripts do not report errors to the output that you can see. Instead you have 2 options. option 1, put the script in a normal script for debugging purposes, so it will produce a visible output. option 2, use the pcall function to create a string value holding the error message in a designated "Error Log" directory. Note that if your error keeps on executing with pcall creating stringvalues, that studio will freeze, so save before.
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
11 Oct 2012 10:42 PM
In test mode Local script error do show up, I get them more then I probably should.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
11 Oct 2012 10:44 PM
I put it in a normal script and still received no output.
Report Abuse
ArbiterOfDeath is not online. ArbiterOfDeath
Joined: 20 Jun 2011
Total Posts: 1458
11 Oct 2012 10:59 PM
Try this. I have to leave now, and diden't get to finish my revision, and can't tell you all that was wrong with it. good luck.

local tool = script.Parent.Parent
local s = Instance.new("Smoke")
local v = Instance.new("StringValue")

function Equipped(m)
if tool.Parent.Parent.ClassName == "Player" then
v.Parent = script.Parent
v.Value = tool.Parent.Parent.Name
m.Button1Down:connect(onButton1Down)
end
end

function onButton1Down(mouse)
local m = Game.Players.LocalPlayer:GetMouse()
script.Parent.Position = m.Hit.p
tool.Parent = game.Workspace
script.Parent.Anchored = true
script.Parent.CanCollide = true
tool = game.Workspace
game.Workspace.TacticalInsertion:Remove()
s.Parent = script.Parent
s.Opacity = 0.2
s.RiseVelocity = 1
s.Size = 1
s.Color = Color3.new(0, 128, 0)
end

function OnPlayerAdded(player)
local character = player.Character
while player.Character == nil do
player.Changed:wait()
end
if character.Name == v.Value then
player.Torso.CFrame = CFrame.new(script.Parent.Position)
script.Parent:Destroy()
end
end

tool.Equipped:connect(Equipped)
tool.Unequipped:connect(Equipped)
game.Players.PlayerAdded:connect(OnPlayerAdded)
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
11 Oct 2012 11:09 PM
That didn't work..
Report Abuse
AdvorsusDuo is not online. AdvorsusDuo
Joined: 17 May 2012
Total Posts: 5265
12 Oct 2012 07:00 AM
Using tools>test>Play Solo, local scripts will print to the output
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Oct 2012 12:20 PM
I tried Play Solo, and still received no output.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Oct 2012 01:06 PM
Bump.
Report Abuse
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
12 Oct 2012 01:11 PM
Why do you want PlayerAdded in a tool?
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Oct 2012 01:18 PM
Er..

I remove the tool after I reparent the handle. I'm wanting it to move the player to the location of the handle when the player dies. Everything in my original script appears to work except moving the player when they respawn.

So to answer your question, I have it as a tool to be able to set the name of the player so that it knows who to respawn.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Oct 2012 02:07 PM
Bump.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Oct 2012 02:36 PM
Bump..
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Oct 2012 05:58 PM
Bump...
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Oct 2012 06:16 PM
Bump....
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Oct 2012 06:41 PM
Bump.....
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Oct 2012 09:08 PM
Bumpity bumpity bumpity
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Oct 2012 09:41 PM
Bawmp.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Oct 2012 10:48 PM
Can I have some help please?
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
12 Oct 2012 11:04 PM
s = Instance.new("Smoke")
v = Instance.new("StringValue")
function Equipped()
if script.Parent.Parent.Parent.Parent.ClassName == "Player" then --big problem will error
else end

v.Parent = script.Parent
v.Value = script.Parent.Parent.Parent.Parent.Name

end
end

script.Parent.Parent.Equipped:connect(Equipped)
script.Parent.Parent.Unequipped:connect(Equipped)

function onButton1Down(mouse)
local p = Game.Players.LocalPlayer
local m = p:GetMouse()
script.Parent.Position = Vector3.new(m.Hit)
script.Parent.Parent.Parent = game.Workspace
script.Parent.Anchored = true
script.Parent.CanCollide = true
script.Parent.Parent = game.Workspace
game.Workspace.TacticalInsertion:Remove()
s.Parent = script.Parent
s.Opacity = 0.2
s.RiseVelocity = 1
s.Size = 1
s.Color = Color3.new(0, 128, 0)
end
script.Parent.Parent.Equipped:connect(function(m) m.Button1Down:connect(onButton1Down)end)

-- I think script stops working under this line

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
--Player = game.Players.PlayerAdded
if Character.Name == v.Value then
Player.Torso.CFrame = CFrame.new(script.Parent.Position)
script.Parent:Remove()
end
end)
end)
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
12 Oct 2012 11:29 PM
"if script.Parent.Parent.Parent.Parent.ClassName == "Player" then --big problem will error"

???

That part works just fine..
The problem is that it won't move the player once they respawn..
And no, that didn't fix it.
Report Abuse
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
13 Oct 2012 08:40 AM
It will move the next person who enters the game >_>
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
13 Oct 2012 12:40 PM
Okay, then how do I make it move said player when they respawn?
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