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
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 09 Jul 2015 09:43 AM |
bump
what makes it so laggy |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 09 Jul 2015 10:21 AM |
| Upgrade your internet speed. |
|
|
| Report Abuse |
|
|