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 » Game Design
Home Search
 

Re: [SH] Fixing scripts

Previous Thread :: Next Thread 
AgentL3r is not online. 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 is not online. 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 is not online. AgentL3r
Joined: 14 Jan 2013
Total Posts: 1671
22 Nov 2014 11:28 AM
^ why thank you kind sir
Report Abuse
AgentL3r is not online. AgentL3r
Joined: 14 Jan 2013
Total Posts: 1671
22 Nov 2014 11:32 AM
^ Making it a local script brakes everything :(
Report Abuse
KingJacko is not online. 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 is not online. 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 is not online. KingJacko
Joined: 20 Jun 2008
Total Posts: 3944
22 Nov 2014 11:47 AM
idunnothen
Report Abuse
lordrambo is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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