|
| 15 Apr 2012 03:09 PM |
I'm trying to invent a tool in which turns your character into the character you click, unfortunately, every time I test it, roblox shuts down! Here's the script:
if game.Players:GetPlayerFromCharacter(clicked.Parent) ~= nil then local Player = game.Players:GetPlayerFromCharacter(clicked.Parent) local Char = game.Lighting.Character:Clone() Char.Parent = game.Workspace Char:MoveTo(game.Players.LocalPlayer.Character.Torso.Position) end game.Players.LocalPlayer.Character = clicked.Parent Player.Character = Char
'clicked' is a variable defining the mouse target. |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2012 03:12 PM |
Is this a tool or mousedetector.. or ?
† KMXD † |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2012 03:13 PM |
| This is part of a LocalScript in a hopperbin. |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 Apr 2012 04:28 PM |
| Is it registering the Char as nil? |
|
|
| Report Abuse |
|
|
breuning
|
  |
| Joined: 30 Oct 2008 |
| Total Posts: 4268 |
|
|
| 15 Apr 2012 04:33 PM |
| "Char = game.Lighting.Character:Clone()" -- Is there a Character in Lighting? |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2012 04:36 PM |
| I ran a few print statements, and it lags out at the 'GetPlayerFromCharacter' |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2012 04:37 PM |
| And yes, char is in lighting. I made this script, anyways I'm testing it on NPC's so that part of the if statement shouldn't even register. |
|
|
| Report Abuse |
|
|
breuning
|
  |
| Joined: 30 Oct 2008 |
| Total Posts: 4268 |
|
| |
|
| |
|
breuning
|
  |
| Joined: 30 Oct 2008 |
| Total Posts: 4268 |
|
| |
|
|
| 15 Apr 2012 04:53 PM |
| Is GetPlayrtFromCharacter() broken? |
|
|
| Report Abuse |
|
|
breuning
|
  |
| Joined: 30 Oct 2008 |
| Total Posts: 4268 |
|
|
| 15 Apr 2012 04:56 PM |
| You can't GetPlayerFromCharacter from a NPC. |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2012 05:22 PM |
| Yes, but it should return nil if the object isn't a player. |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2012 05:23 PM |
| Anyways, I tested it on a server as well. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
Phellem
|
  |
| Joined: 04 Aug 2011 |
| Total Posts: 1984 |
|
|
| 15 Apr 2012 07:51 PM |
local Char = game.Lighting.Character:Clone() Char.Parent = game.Workspace Char:MoveTo(game.Players.LocalPlayer.Character.Torso.Position) end game.Players.LocalPlayer.Character = clicked.Parent Player.Character = Char
'Char' is cut off by the end. The local Char does not work anymore. |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2012 07:59 PM |
^
I already changed that. =/ |
|
|
| Report Abuse |
|
|
| |
|
| |
|
Phellem
|
  |
| Joined: 04 Aug 2011 |
| Total Posts: 1984 |
|
|
| 16 Apr 2012 12:16 PM |
| Could you post the full script. -.- |
|
|
| Report Abuse |
|
|
|
| 16 Apr 2012 01:03 PM |
local mouse = nil local mode = "Power" local FireReload = false local IceReload = false local ExplosionReload = false local ShieldReload = false local PowerReload = false local PunchConnection = nil local LPunchConnection = nil local PunchReload = false local LPunchReload = false local SpyReload = false local Player = nil local Char = nil function Enabled(m) mouse = m mouse.KeyDown:connect(onKeyDown) mouse.Button1Down:connect(Click) end script.Parent.Selected:connect(Enabled)
function Unequipped() mouse = nil end script.Parent.Deselected:connect(Unequipped)
function onKeyDown(key) if key == "f" or key == "F" then mode = "Fire" elseif key == "q" or key == "Q" then mode = "Ice" elseif key == "e" or key == "E" then mode = "Explode" elseif key == "h" or key == "H" then mode = "Shield" elseif key == "p" or key == "P" then mode = "Power" elseif key == "t" or key == "T" then mode = "Punch" elseif key == "y" or key == "Y" then mode = "LPunch" elseif key == "c" or key == "C" then mode = "Spy" end end
function Click() local clicked = mouse.Target if mode == "Fire" and clicked~=nil and clicked.Parent:FindFirstChild("Humanoid")~=nil and FireReload == false then FireReload = true local fire = Instance.new("Fire") fire.Parent = clicked fire.Size = 10 fire.Heat = 25 fire.Name = "Fire" fire.Color = BrickColor.new("Navy blue").Color fire.SecondaryColor = BrickColor.new("Bright orange").Color fire.Archivable = false for num = 1,50 do clicked.Parent.Humanoid:TakeDamage(1) wait(0.1) fire.Heat = fire.Heat-1 end fire:Destroy() wait(10) FireReload = false elseif mode == "Ice" and clicked.Parent:FindFirstChild("Humanoid")~=nil and IceReload == false then IceReload = true local lasso = Instance.new("SelectionPartLasso") lasso.Parent = game.Players.LocalPlayer.Character lasso.Humanoid = game.Players.LocalPlayer.Character.Humanoid lasso.Part = clicked lasso.Color = BrickColor.new("Bright blue") lasso.Transparency = 0 lasso.Name = "SelectionPartLasso" lasso.Visible = true lasso.Archivable = false clicked.Parent.Head.Anchored = true clicked.Parent.Head.BrickColor = BrickColor.new("Bright blue") clicked.Parent.Head.Reflectance = 0.5 clicked.Parent.Humanoid:TakeDamage(10) wait(1) clicked.Parent.Head.Anchored = false lasso:Destroy() wait(10) IceReload = false elseif mode == "Explode" and ExplosionReload == false then ExplosionReload = true Instance.new("ForceField",game.Players.LocalPlayer.Character) local explosion = Instance.new("Explosion") explosion.Parent = game.Workspace explosion.Position = game.Players.LocalPlayer.Character.Torso.Position explosion.BlastPressure = 1000 explosion.BlastRadius = 3 explosion.ExplosionType = 0 explosion.Name = "This is obviously an Explosion." explosion.Archivable = false wait(0.1) game.Players.LocalPlayer.Character.ForceField:Destroy() wait(100) ExplosionReload = false elseif mode == "Shield" then ShieldReload = true Instance.new("ForceField",game.Players.LocalPlayer.Character) wait(5) game.Players.LocalPlayer.Character.ForceField:Destroy() wait(25) ShieldReload = false elseif mode == "Power" and clicked.Parent:FindFirstChild("Humanoid") and PowerReload == false then PowerReload = true local lasso = Instance.new("SelectionPartLasso") lasso.Parent = game.Players.LocalPlayer.Character lasso.Humanoid = game.Players.LocalPlayer.Character.Humanoid lasso.Part = clicked lasso.Color = BrickColor.new("Institutional white") lasso.Transparency = 0 lasso.Name = "SelectionPartLasso" lasso.Visible = true lasso.Archivable = false wait(0.5) lasso:Destroy() clicked:Destroy() wait(100) PowerReload = false elseif mode == "Punch" and PunchReload == false then PunchReload = true PunchConnection = game.Players.LocalPlayer.Character:FindFirstChild("Right Arm").Touched:connect(Punch) local right_shoulder = game.Players.LocalPlayer.Character.Torso:FindFirstChild("Right Shoulder") right_shoulder.CurrentAngle = 2 wait(0.3) PunchConnection:disconnect() wait(3) PunchReload = false elseif mode == "LPunch" and LPunchReload == false then LPunchReload = true LPunchConnection = game.Players.LocalPlayer.Character:FindFirstChild("Left Arm").Touched:connect(LPunch) local left_shoulder = game.Players.LocalPlayer.Character.Torso:FindFirstChild("Left Shoulder") left_shoulder.CurrentAngle = -2 wait(0.3) LPunchConnection:disconnect() LPunchReload = false elseif mode == "Spy" and SpyReload == false and clicked.Parent:FindFirstChild("Humanoid") ~= nil then SpyReload = true if game.Players:GetPlayerFromCharacter(clicked.Parent) ~= nil then Player = game.Players:GetPlayerFromCharacter(clicked.Parent) Char = game.Lighting.Character:Clone() Char.Parent = game.Workspace Char:MoveTo(game.Players.LocalPlayer.Character.Torso.Position) else Char = nil Player = nil end game.Players.LocalPlayer.Character = clicked.Parent Player.Character = Char wait(10) SpyReload = false end end
function Punch(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then hit.Parent.Torso.Velocity = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector * 250 hit.Parent.Humanoid:TakeDamage(20) end end function LPunch(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then hit.Parent.Humanoid.PlatformStand = true hit.Parent.Humanoid:TakeDamage(20) wait(3) hit.Parent.Humanoid.PlatformStand = false end end |
|
|
| Report Abuse |
|
|
| |
|
Torcus
|
  |
| Joined: 22 Feb 2012 |
| Total Posts: 885 |
|
|
| 16 Apr 2012 06:20 PM |
Cloning a character by just one click and making yourself them is like hat-jacker. This take 2x the scripting lines.
Nobody will do that long script you posted. |
|
|
| Report Abuse |
|
|