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 » Scripters
Home Search
 

Re: script working so much smoother in solo than online

Previous Thread :: Next Thread 
OzzyFin is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
09 Jul 2015 08:42 AM
I have FE enabled, so I can't just create the 'lasers' I have from localscript if I want to show them to everyone, so I am using a RemoteEvent to create the laser with properties:

createinstance.OnServerEvent:connect(function(plr,type,args,kill,laser,vehicle)
local obj = Instance.new(type)
for prop,val in pairs(args) do
obj[prop] = val
end
-- some checking when obj hits something if kill equals true
end

when I had this exact same function inside my localscript (well obv without onserverevent) it worked as smooth in online as it works in play solo, but I want others to see those parts aswell.

mk well the problem is that the part I create gets stuck for about .1-.2 seconds into the very first position I put it in, then launches into the air or wherever I click.

I'm pretty bad at explaining this but if you want to see what I mean check
http://www.roblox.com/games/267022524/--

and in case this matters:

createinstance:FireServer("Part",{["FormFactor"] = Enum.FormFactor.Custom,["Size"] = Vector3.new(.2,.2,4),["CFrame"] = CFrame.new(start.CFrame.p,mouse.Hit.p)*CFrame.new(0,0,-2.5),["Velocity"] = -dir}) -- more properties here it was so long I cut it out
Report Abuse
OzzyFin is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
09 Jul 2015 09:43 AM
bump

what makes it so laggy
Report Abuse
GiganticGulian is not online. GiganticGulian
Joined: 18 Feb 2011
Total Posts: 2233
09 Jul 2015 09:46 AM
it takes time to send data to the server and back

so when you fire it sends a signal to the server to create a part and then it returns with the resulting part
this takes a few milliseconds

what you do is make the part locally from your local script
then send a signal to the server to tell the other clients that you have fired a part with couple of traits listed in a table
those other clients make the part you fired all for themselves

then you have a fast and efficient FE gun
Report Abuse
GiganticGulian is not online. GiganticGulian
Joined: 18 Feb 2011
Total Posts: 2233
09 Jul 2015 09:51 AM
-- gunscript:

game.ReplicatedStorage.BulletReplicator:FireServer({Size = part.Size, BrickColor = part.BrickColor --[[ et cetera ]]})

-- serverscript:

game.ReplicatedStorage.BulletReplicator.OnServerEvent:connect(function(player, traits)
game.ReplicatedStorage.BulletReplicator:FireAllClients(player, traits)
end)

-- an external script inside each client to display bullets:

local Player = game.Players.LocalPlayer

game.ReplicatedStorage.BulletReplicator.OnClientEvent:connect(function(player, traits)
if player ~= Player then -- you wouldn't want to create a second ray, would you?
local part = Instance.new("Part")
for i, v in pairs(traits) do -- setting the traits
part[i] = v
end
end
end
Report Abuse
OzzyFin is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
09 Jul 2015 10:03 AM
Yea I just needed the idea on how to fix this not an actual code, but thank you, works great.
Report Abuse
superkilomario is not online. superkilomario
Joined: 06 Jul 2015
Total Posts: 672
09 Jul 2015 10:21 AM
Upgrade your internet speed.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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