AgentL3r
|
  |
| Joined: 14 Jan 2013 |
| Total Posts: 1671 |
|
|
| 22 Nov 2014 11:20 AM |
Hello.
The following script only works in play solo mode, and not in-game, any thoughts why?
Distance = 20
Player = script.Parent.Parent.Parent if Player:findFirstChild("GUIBackpack") then Bp = Player["GUIBackpack"] else Bp = Instance.new("Model") Bp.Name = "GUIBackpack" Bp.Parent = Player end
Tool = script.Parent
Tool.Selected:connect(function(Mouse) if Player.PlayerGui:findFirstChild("PickSlect") then Vp = Player.PlayerGui["PickSlect"] else Vp = Instance.new("ScreenGui") Vp.Name = "PickSlect" Vp.Parent = Player.PlayerGui Info = Instance.new("TextLabel") Info.Parent = Vp Info.Name = "Info" Info.Size = UDim2.new(0,300,0,20) Info.Position = UDim2.new(0,200,1,-20) Info.Text = "Press 'E' to add thing (you have to be max "..Distance.." studs away)" end if Vp:findFirstChild("Slect") then Sp = Vp["Slect"] else Sp = Instance.new("SelectionBox") Sp.Name = "Slect" Sp.Parent = Vp end Mouse.Button1Down:connect(function() pcall(function() if (Mouse.Target.Position - Player.Character.Head.Position).magnitude < Distance then if Mouse.Target:findFirstChild("AllowPick") and not Mouse.Target:findFirstChild("NoPick") then Sp.Adornee = Mouse.Target end if Mouse.Target.Parent:findFirstChild("AllowPick") and not Mouse.Target.Parent:findFirstChild("NoPick") then Sp.Adornee = Mouse.Target end end end) end) Mouse.KeyDown:connect(function(k) pcall(function() if (Sp.Adornee.Position - Player.Character.Head.Position).magnitude < Distance then if Sp.Adornee:findFirstChild("AllowPick") and k == "e" and not Sp.Adornee:findFirstChild("NoPick") then Sp.Adornee.Parent = Bp end if Sp.Adornee.Parent:findFirstChild("AllowPick") and k == "e" and not Sp.Adornee.Parent:findFirstChild("NoPick") then Sp.Adornee.Parent.Parent = Bp end end end) end) end)
Tool.Deselected:connect(function(Mouse) if Player.PlayerGui:findFirstChild("PickSlect") then Player.PlayerGui["PickSlect"]:Remove() end end) |
|
|
| Report Abuse |
|
|
KingJacko
|
  |
| Joined: 20 Jun 2008 |
| Total Posts: 3944 |
|
|
| 22 Nov 2014 11:23 AM |
make it LocalScript then Player = Game:GetService("Players").LocalPlayer
idk this might work |
|
|
| Report Abuse |
|
|
AgentL3r
|
  |
| Joined: 14 Jan 2013 |
| Total Posts: 1671 |
|
| |
|
AgentL3r
|
  |
| Joined: 14 Jan 2013 |
| Total Posts: 1671 |
|
|
| 22 Nov 2014 11:32 AM |
| ^ Making it a local script brakes everything :( |
|
|
| Report Abuse |
|
|
KingJacko
|
  |
| Joined: 20 Jun 2008 |
| Total Posts: 3944 |
|
|
| 22 Nov 2014 11:42 AM |
| ye np i had this prob so many times its burnt into my brain |
|
|
| Report Abuse |
|
|
AgentL3r
|
  |
| Joined: 14 Jan 2013 |
| Total Posts: 1671 |
|
|
| 22 Nov 2014 11:44 AM |
Works in build mode, doesent work in game.
Local script doesent work. |
|
|
| Report Abuse |
|
|
KingJacko
|
  |
| Joined: 20 Jun 2008 |
| Total Posts: 3944 |
|
| |
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 22 Nov 2014 11:50 AM |
Local scripts usually try to run before the player arrives so at the top of the script (as the first line) put game.Players.LocalPlayer.Character:Wait() |
|
|
| Report Abuse |
|
|
AgentL3r
|
  |
| Joined: 14 Jan 2013 |
| Total Posts: 1671 |
|
|
| 22 Nov 2014 11:58 AM |
let me rephrase
the script as it is (not local) works in build mode, and not in game
local script doesent work at all |
|
|
| Report Abuse |
|
|