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: Why won't this work in Online/Server? It works in SOLO.

Previous Thread :: Next Thread 
harvest109 is not online. harvest109
Joined: 19 Jun 2011
Total Posts: 869
24 Sep 2014 07:00 AM
No errors in SOLO/Online or Server
local Player = game.Players.LocalPlayer
repeat wait() until Player.Character ~= nil
local Player = game.Players.LocalPlayer
local Char = game.Players.LocalPlayer.Character
local mouse = Player:GetMouse()
local Camera = game.Workspace.CurrentCamera
local Store = game:GetService("ServerStorage")
local MouseHover = Store:WaitForChild("Mousehover")
local H = MouseHover:Clone()
H.Parent = Camera
local click = 0

mouse.Move:connect(function()
print(click)
if mouse.Target == nil then
print'Target is nil'
return
elseif click == 0 then
print'Target is not nil'
H.Position = mouse.Target.Position
end
end)

mouse.Button1Down:connect(function()
print(click)
click = 1
Char:WaitForChild("Humanoid")
Char.Humanoid:MoveTo(H.Position,H)
end)

H.Touched:connect(function()
if click == 1 then
print(click)
click = 0
end
end)

Char:WaitForChild("Humanoid").Died:connect(function()
H:Destroy()
end)

Report Abuse
harvest109 is not online. harvest109
Joined: 19 Jun 2011
Total Posts: 869
24 Sep 2014 04:31 PM
Help!?
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
24 Sep 2014 04:34 PM
First - make sure it's in a localscript
Second - add wait(2) before everything
Thrid - why define Player twice and not even use it properly?
Report Abuse
harvest109 is not online. harvest109
Joined: 19 Jun 2011
Total Posts: 869
25 Sep 2014 06:17 PM
repeat wait() until game.Players.LocalPlayer.Character ~= nil
local Player = game.Players.LocalPlayer
local Char = game.Players.LocalPlayer.Character
local mouse = Player:GetMouse()
local Camera = game.Workspace.CurrentCamera
local Store = game:GetService("ServerStorage")
local MouseHover = Store:WaitForChild("Mousehover")
local H = MouseHover:Clone()
H.Parent = Camera
local click = 0

wait(2)
mouse.Move:connect(function()
if mouse.Target == nil then
return
elseif click == 0 then
H.Position = mouse.Target.Position
end
end)
wait(2)
mouse.Button1Down:connect(function()
click = 1
Char:WaitForChild("Humanoid")
Char.Humanoid:MoveTo(H.Position,H)
end)
wait(2)
H.Touched:connect(function()
if click == 1 then
click = 0
end
end)
wait(2)
Char:WaitForChild("Humanoid").Died:connect(function()
H:Destroy()
end)
Report Abuse
cooldude999921 is not online. cooldude999921
Joined: 13 Aug 2011
Total Posts: 3702
25 Sep 2014 06:21 PM
wait(2) -- no


it works better in solo because solo runs on the client's machine, not through the Roblox Servers


Use a repeat method


repeat wait() until InsertCodeHereThatMakesitCheckifTrue


Example:


while wait(2) do
i = 1
v = i + 1
print(i)

repeat wait() until i = 10
break end
Report Abuse
harvest109 is not online. harvest109
Joined: 19 Jun 2011
Total Posts: 869
25 Sep 2014 06:27 PM
I'm quite sorry, can you help me put it together, If you can, or don't mind.
<3
Report Abuse
harvest109 is not online. harvest109
Joined: 19 Jun 2011
Total Posts: 869
25 Sep 2014 06:28 PM
<3 You play Basewars I've got 53k kills 5k deaths
Report Abuse
NewhallDistrict is not online. NewhallDistrict
Joined: 02 Sep 2014
Total Posts: 308
25 Sep 2014 06:33 PM
"Add wait(2)"

lmao


wait() would do the trick just fine
Report Abuse
cooldude999921 is not online. cooldude999921
Joined: 13 Aug 2011
Total Posts: 3702
25 Sep 2014 06:34 PM
nah


wait(2) is bad


wait(3) is better

or repeat wait()
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