· 6 years ago · Oct 17, 2019, 09:56 AM
1-- This script has been converted to FE by iPxter
2
3
4if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
5local Player,Mouse,mouse,UserInputService,ContextActionService = owner
6do
7 print("FE Compatibility code by Mokiros | Translated to FE by iPxter")
8 script.Parent = Player.Character
9
10 --RemoteEvent for communicating
11 local Event = Instance.new("RemoteEvent")
12 Event.Name = "UserInput_Event"
13
14 --Fake event to make stuff like Mouse.KeyDown work
15 local function fakeEvent()
16 local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
17 t.connect = t.Connect
18 return t
19 end
20
21 --Creating fake input objects with fake variables
22 local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
23 local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
24 local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
25 CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
26 end}
27 --Merged 2 functions into one by checking amount of arguments
28 CAS.UnbindAction = CAS.BindAction
29
30 --This function will trigger the events that have been :Connect()'ed
31 local function te(self,ev,...)
32 local t = m[ev]
33 if t and t._fakeEvent and t.Function then
34 t.Function(...)
35 end
36 end
37 m.TrigEvent = te
38 UIS.TrigEvent = te
39
40 Event.OnServerEvent:Connect(function(plr,io)
41 if plr~=Player then return end
42 if io.isMouse then
43 m.Target = io.Target
44 m.Hit = io.Hit
45 else
46 local b = io.UserInputState == Enum.UserInputState.Begin
47 if io.UserInputType == Enum.UserInputType.MouseButton1 then
48 return m:TrigEvent(b and "Button1Down" or "Button1Up")
49 end
50 for _,t in pairs(CAS.Actions) do
51 for _,k in pairs(t.Keys) do
52 if k==io.KeyCode then
53 t.Function(t.Name,io.UserInputState,io)
54 end
55 end
56 end
57 m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
58 UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
59 end
60 end)
61 Event.Parent = NLS([==[
62 local Player = game:GetService("Players").LocalPlayer
63 local Event = script:WaitForChild("UserInput_Event")
64
65 local UIS = game:GetService("UserInputService")
66 local input = function(io,a)
67 if a then return end
68 --Since InputObject is a client-side instance, we create and pass table instead
69 Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
70 end
71 UIS.InputBegan:Connect(input)
72 UIS.InputEnded:Connect(input)
73
74 local Mouse = Player:GetMouse()
75 local h,t
76 --Give the server mouse data 30 times every second, but only if the values changed
77 --If player is not moving their mouse, client won't fire events
78 while wait(1/30) do
79 if h~=Mouse.Hit or t~=Mouse.Target then
80 h,t=Mouse.Hit,Mouse.Target
81 Event:FireServer({isMouse=true,Target=t,Hit=h})
82 end
83 end]==],Player.Character)
84 Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
85end
86
87print[[
88 Created by Biologically_Noob
89 Disc: Bio#6428
90 Help from MonolithicDivinity and Cron
91 VengefulProgram's House
92 Updoot log
93 The decoration update
94 Added:
95 -Sword on the wall
96 -Jojo boie
97 -FORKING FLOWERS THAT I FORGOT TO ANCHOR
98 -Clock that doesn't work
99 -Drawer with a lamp
100 -Materials to the bed
101 -Sum decorations
102
103]]
104-- Thanks for using Mod2S by NopeUsername
105local functions = {}
106function sandbox(script, func)
107 local oldEnv = getfenv(func)
108 local newEnv = setmetatable({}, {
109 __index = function(self,k)
110 if k == "script" then
111 return script
112 else
113 return oldEnv[k]
114 end
115 end,
116 })
117 return setfenv(func, newEnv)
118end
119local mas = Instance.new("Model", game:GetService("Lighting"))
120local RocketLauncher = Instance.new("Tool")
121local Handle = Instance.new("Part")
122local Mesh = Instance.new("SpecialMesh")
123local Script = Instance.new("Script")
124local Boom = Instance.new("Sound")
125local Swoosh = Instance.new("Sound")
126local Rocket = Instance.new("Script")
127local LocalScript = Instance.new("LocalScript")
128local Configurations = Instance.new("Configuration")
129local AttackCooldown = Instance.new("NumberValue")
130local Damage = Instance.new("IntValue")
131local ReloadTime = Instance.new("NumberValue")
132local BlastForce = Instance.new("IntValue")
133local BlastRadius = Instance.new("IntValue")
134local RocketSpeed = Instance.new("IntValue")
135local ScreenSpace = Instance.new("ModuleScript")
136RocketLauncher.CanBeDropped = false
137RocketLauncher.Grip = CFrame.new(0.7,0,-0.5,0,0,-1,-1,0,0,0,1,0)
138RocketLauncher.GripForward = Vector3.new(1,0,0)
139RocketLauncher.GripPos = Vector3.new(0.7,0,-0.5)
140RocketLauncher.GripRight = Vector3.new(0,-1,0)
141RocketLauncher.GripUp = Vector3.new(0,0,1)
142RocketLauncher.TextureId = "http://www.roblox.com/asset/?id=90021376"
143RocketLauncher.Name = "RocketLauncher"
144RocketLauncher.Parent = mas
145Handle.BottomSurface = Enum.SurfaceType.Smooth
146Handle.CFrame = CFrame.new(3.994,0.42,65.507,1,0,0,0,0,1,0,-1,0)
147Handle.Size = Vector3.new(4.92,0.74,0.84)
148Handle.TopSurface = Enum.SurfaceType.Smooth
149Handle.Name = "Handle"
150Handle.Parent = RocketLauncher
151Mesh.MeshType = Enum.MeshType.FileMesh
152Mesh.MeshId = "rbxasset://fonts/rocketlauncher.mesh"
153Mesh.TextureId = "rbxasset://textures/rocketlaunchertex.png"
154Mesh.Scale = Vector3.new(0.75,0.75,0.75)
155Mesh.Parent = Handle
156table.insert(functions,sandbox(Script,function()
157local tool = script.Parent
158local canFire = true
159local gunWeld
160-----------------
161--| Constants |--
162-----------------
163local GRAVITY_ACCELERATION = 196.2
164local RELOAD_TIME = tool.Configurations.ReloadTime.Value -- Seconds until tool can be used again
165local ROCKET_SPEED = tool.Configurations.RocketSpeed.Value -- Speed of the projectile
166local MISSILE_MESH_ID = 'http://www.roblox.com/asset/?id=2251534'
167local MISSILE_MESH_SCALE = Vector3.new(0.35, 0.35, 0.25)
168local ROCKET_PART_SIZE = Vector3.new(1.2, 1.2, 3.27)
169local RocketScript = script:WaitForChild('Rocket')
170local SwooshSound = script:WaitForChild('Swoosh')
171local BoomSound = script:WaitForChild('Boom')
172local attackCooldown = tool.Configurations.AttackCooldown.Value
173local damage = tool.Configurations.Damage.Value
174local reloadTime = tool.Configurations.ReloadTime.Value
175local function createEvent(eventName)
176 local event = game.ReplicatedStorage:FindFirstChild(eventName)
177 if not event then
178 event = Instance.new("RemoteEvent", game.ReplicatedStorage)
179 event.Name = eventName
180 end
181 return event
182end
183local updateEvent = createEvent("ROBLOX_RocketUpdateEvent")
184local equipEvent = createEvent("ROBLOX_RocketEquipEvent")
185local unequipEvent = createEvent("ROBLOX_RocketUnequipEvent")
186local fireEvent = createEvent("ROBLOX_RocketFireEvent")
187updateEvent.OnServerEvent:connect(function(player, neckC0, rshoulderC0)
188 local character = player.Character
189 local humanoid = character.Humanoid
190 if humanoid.Health <= 0 then return end
191 if humanoid.RigType == Enum.HumanoidRigType.R6 then
192 character.Torso.Neck.C0 = neckC0
193 character.Torso:FindFirstChild("Right Shoulder").C0 = rshoulderC0
194 gunWeld = character:FindFirstChild("Right Arm"):WaitForChild("RightGrip")
195 elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
196 character.Head.Neck.C0 = neckC0
197 character.RightUpperArm.RightShoulder.C0 = rshoulderC0
198 gunWeld = character.RightHand:WaitForChild("RightGrip")
199 end
200end)
201equipEvent.OnServerEvent:connect(function(player)
202 player.Character.Humanoid.AutoRotate = false
203end)
204unequipEvent.OnServerEvent:connect(function(player)
205 player.Character.Humanoid.AutoRotate = true
206end)
207--NOTE: We create the rocket once and then clone it when the player fires
208local Rocket = Instance.new('Part') do
209 -- Set up the rocket part
210 Rocket.Name = 'Rocket'
211 Rocket.FormFactor = Enum.FormFactor.Custom --NOTE: This must be done before changing Size
212 Rocket.Size = ROCKET_PART_SIZE
213 Rocket.CanCollide = false
214 -- Add the mesh
215 local mesh = Instance.new('SpecialMesh', Rocket)
216 mesh.MeshId = MISSILE_MESH_ID
217 mesh.Scale = MISSILE_MESH_SCALE
218 -- Add fire
219 local fire = Instance.new('Fire', Rocket)
220 fire.Heat = 5
221 fire.Size = 2
222 -- Add a force to counteract gravity
223 local bodyForce = Instance.new('BodyForce', Rocket)
224 bodyForce.Name = 'Antigravity'
225 bodyForce.force = Vector3.new(0, Rocket:GetMass() * GRAVITY_ACCELERATION, 0)
226 -- Clone the sounds and set Boom to PlayOnRemove
227 local swooshSoundClone = SwooshSound:Clone()
228 swooshSoundClone.Parent = Rocket
229 local boomSoundClone = BoomSound:Clone()
230 boomSoundClone.PlayOnRemove = true
231 boomSoundClone.Parent = Rocket
232 -- Finally, clone the rocket script and enable it
233-- local rocketScriptClone = RocketScript:Clone()
234-- rocketScriptClone.Parent = Rocket
235-- rocketScriptClone.Disabled = false
236end
237fireEvent.OnServerEvent:connect(function(player, target)
238 if canFire and player.Character == tool.Parent then
239 canFire = false
240 -- Create a clone of Rocket and set its color
241 local rocketClone = Rocket:Clone()
242 --game.Debris:AddItem(rocketClone, 30)
243 rocketClone.BrickColor = player.TeamColor
244 rocketClone.Touched:connect(function(hit)
245 if hit and hit.Parent and hit.Parent ~= player.Character and hit.Parent ~= tool then
246 local explosion = Instance.new("Explosion", game.Workspace)
247 explosion.Position = rocketClone.Position
248 rocketClone:Destroy()
249 end
250 end)
251 spawn(function()
252 wait(30)
253 if rocketClone then rocketClone:Destroy() end
254 end)
255 -- Position the rocket clone and launch!
256 local spawnPosition = (tool.Handle.CFrame * CFrame.new(2, 0, 0)).p
257 rocketClone.CFrame = CFrame.new(spawnPosition, target) --NOTE: This must be done before assigning Parent
258 rocketClone.Velocity = rocketClone.CFrame.lookVector * ROCKET_SPEED --NOTE: This should be done before assigning Parent
259 rocketClone.Parent = game.Workspace
260 -- Attach creator tags to the rocket early on
261 local creatorTag = Instance.new('ObjectValue', rocketClone)
262 creatorTag.Value = player
263 creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
264 local iconTag = Instance.new('StringValue', creatorTag)
265 iconTag.Value = tool.TextureId
266 iconTag.Name = 'icon'
267 delay(attackCooldown, function()
268 canFire = true
269 end)
270 end
271end)
272end))
273Script.Parent = RocketLauncher
274Boom.SoundId = "rbxasset://sounds/collide.wav"
275Boom.Volume = 1
276Boom.Name = "Boom"
277Boom.Parent = Script
278Swoosh.Looped = true
279Swoosh.SoundId = "rbxasset://sounds/Rocket whoosh 01.wav"
280Swoosh.Volume = 0.7
281Swoosh.Name = "Swoosh"
282Swoosh.Parent = Script
283table.insert(functions,sandbox(Rocket,function()
284-----------------
285--| Constants |--
286-----------------
287local BLAST_RADIUS = script.Parent.Parent.Configurations.BlastRadius.Value -- Blast radius of the explosion
288local BLAST_DAMAGE = script.Parent.Parent.Configurations.Damage.Value -- Amount of damage done to players
289local BLAST_FORCE = script.Parent.Parent.Configurations.BlastForce.Value -- Amount of force applied to parts
290local IGNORE_LIST = {rocket = 1, handle = 1, effect = 1, water = 1} -- Rocket will fly through things named these
291--NOTE: Keys must be lowercase, values must evaluate to true
292-----------------
293--| Variables |--
294-----------------
295local DebrisService = game:GetService('Debris')
296local PlayersService = game:GetService('Players')
297local Rocket = script.Parent
298local CreatorTag = Rocket:WaitForChild('creator', 60)
299local SwooshSound = Rocket:WaitForChild('Swoosh', 60)
300-----------------
301--| Functions |--
302-----------------
303-- Removes any old creator tags and applies a new one to the target
304local function ApplyTags(target)
305 while target:FindFirstChild('creator') do
306 target.creator:Destroy()
307 end
308 local creatorTagClone = CreatorTag:Clone()
309 DebrisService:AddItem(creatorTagClone, 1.5)
310 creatorTagClone.Parent = target
311end
312-- Returns the ancestor that contains a Humanoid, if it exists
313local function FindCharacterAncestor(subject)
314 if subject and subject ~= game.Workspace then
315 local humanoid = subject:FindFirstChild('Humanoid')
316 if humanoid then
317 return subject, humanoid
318 else
319 return FindCharacterAncestor(subject.Parent)
320 end
321 end
322 return nil
323end
324-- Customized explosive effect that doesn't affect teammates and only breaks joints on dead parts
325local function OnExplosionHit(hitPart, hitDistance, blastCenter)
326 if hitPart and hitDistance then
327 local character, humanoid = FindCharacterAncestor(hitPart.Parent)
328 if character then
329 local myPlayer = CreatorTag.Value
330 if myPlayer and not myPlayer.Neutral then -- Ignore friendlies caught in the blast
331 local player = PlayersService:GetPlayerFromCharacter(character)
332 if player and player ~= myPlayer and player.TeamColor == Rocket.BrickColor then
333 return
334 end
335 end
336 end
337 if humanoid and humanoid.Health > 0 then -- Humanoids are tagged and damaged
338 if hitPart.Name == 'Torso' then
339 ApplyTags(humanoid)
340 humanoid:TakeDamage(BLAST_DAMAGE)
341 end
342 else -- Loose parts and dead parts are blasted
343 if hitPart.Name ~= 'Handle' then
344 hitPart:BreakJoints()
345 local blastForce = Instance.new('BodyForce', hitPart) --NOTE: We will multiply by mass so bigger parts get blasted more
346 blastForce.force = (hitPart.Position - blastCenter).unit * BLAST_FORCE * hitPart:GetMass()
347 DebrisService:AddItem(blastForce, 0.1)
348 end
349 end
350 end
351end
352local function OnTouched(otherPart)
353 if Rocket and otherPart then
354 -- Fly through anything in the ignore list
355 if IGNORE_LIST[string.lower(otherPart.Name)] then
356 return
357 end
358 local myPlayer = CreatorTag.Value
359 if myPlayer then
360 -- Fly through the creator
361 if myPlayer.Character and myPlayer.Character:IsAncestorOf(otherPart) then
362 return
363 end
364 -- Fly through friendlies
365 if not myPlayer.Neutral then
366 local character = FindCharacterAncestor(otherPart.Parent)
367 local player = PlayersService:GetPlayerFromCharacter(character)
368 if player and player ~= myPlayer and player.TeamColor == Rocket.BrickColor then
369 return
370 end
371 end
372 end
373 -- Fly through terrain water
374 if otherPart == game.Workspace.Terrain then
375 --NOTE: If the rocket is large, then the simplifications made here will cause it to fly through terrain in some cases
376 local frontOfRocket = Rocket.Position + (Rocket.CFrame.lookVector * (Rocket.Size.Z / 2))
377 local cellLocation = game.Workspace.Terrain:WorldToCellPreferSolid(frontOfRocket)
378 local cellMaterial = game.Workspace.Terrain:GetCell(cellLocation.X, cellLocation.Y, cellLocation.Z)
379 if cellMaterial == Enum.CellMaterial.Water or cellMaterial == Enum.CellMaterial.Empty then
380 return
381 end
382 end
383 -- Create the explosion
384 local explosion = Instance.new('Explosion')
385 explosion.BlastPressure = 0 -- Completely safe explosion
386 explosion.BlastRadius = BLAST_RADIUS
387 explosion.ExplosionType = Enum.ExplosionType.NoCraters
388 explosion.Position = Rocket.Position
389 explosion.Parent = game.Workspace
390 -- Connect custom logic for the explosion
391 explosion.Hit:connect(function(hitPart, hitDistance) OnExplosionHit(hitPart, hitDistance, explosion.Position) end)
392 -- Move this script and the creator tag (so our custom logic can execute), then destroy the rocket
393 script.Parent = explosion
394 CreatorTag.Parent = script
395 Rocket:Destroy()
396 end
397end
398--------------------
399--| Script Logic |--
400--------------------
401SwooshSound:Play()
402Rocket.Touched:connect(OnTouched)
403end))
404Rocket.Name = "Rocket"
405Rocket.Parent = Script
406table.insert(functions,sandbox(LocalScript,function()
407-- Variables for services
408local render = game:GetService("RunService").RenderStepped
409local contextActionService = game:GetService("ContextActionService")
410local userInputService = game:GetService("UserInputService")
411local player = game.Players.LocalPlayer
412local mouse = player:GetMouse()
413local Tool = script.Parent
414-- Variables for Module Scripts
415local screenSpace = require(Tool:WaitForChild("ScreenSpace"))
416local connection
417local neck, shoulder, oldNeckC0, oldShoulderC0
418local mobileShouldTrack = true
419-- Thourough check to see if a character is sitting
420local function amISitting(character)
421 return character.Humanoid.SeatPart ~= nil
422end
423-- Function to call on renderstepped. Orients the character so it is facing towards
424-- the player mouse's position in world space. If character is sitting then the torso
425-- should not track
426local function frame(mousePosition)
427 -- Special mobile consideration. We don't want to track if the user was touching a ui
428 -- element such as the movement controls. Just return out of function if so to make sure
429 -- character doesn't track
430 if not mobileShouldTrack then return end
431 --This math is completely wrong with R15. We're better off just not doing it at all
432 if player.Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
433 return
434 end
435 -- Make sure character isn't swiming. If the character is swimming the following code will
436 -- not work well; the character will not swim correctly. Besides, who shoots underwater?
437 if player.Character.Humanoid:GetState() ~= Enum.HumanoidStateType.Swimming then
438 local torso = player.Character.HumanoidRootPart
439 local head = player.Character.Head
440 local toMouse = (mousePosition - head.Position).unit
441 local angle = math.acos(toMouse:Dot(Vector3.new(0,1,0)))
442 local neckAngle = angle
443 -- Limit how much the head can tilt down. Too far and the head looks unnatural
444 if math.deg(neckAngle) > 110 then
445 neckAngle = math.rad(110)
446 end
447 neck.C0 = CFrame.new(0,1,0) * CFrame.Angles(math.pi - neckAngle,math.pi,0)
448 -- Calculate horizontal rotation
449 local arm do
450 arm = player.Character:FindFirstChild("Right Arm") or
451 player.Character:FindFirstChild("RightUpperArm")
452 end
453 local fromArmPos = torso.Position + torso.CFrame:vectorToWorldSpace(Vector3.new(
454 torso.Size.X/2 + arm.Size.X/2, torso.Size.Y/2 - arm.Size.Z/2, 0))
455 local toMouseArm = ((mousePosition - fromArmPos) * Vector3.new(1,0,1)).unit
456 local look = (torso.CFrame.lookVector * Vector3.new(1,0,1)).unit
457 local lateralAngle = math.acos(toMouseArm:Dot(look))
458 -- Check for rogue math
459 if tostring(lateralAngle) == "-1.#IND" then
460 lateralAngle = 0
461 end
462 -- Handle case where character is sitting down
463 if player.Character.Humanoid:GetState() == Enum.HumanoidStateType.Seated then
464 local cross = torso.CFrame.lookVector:Cross(toMouseArm)
465 if lateralAngle > math.pi/2 then
466 lateralAngle = math.pi/2
467 end
468 if cross.Y < 0 then
469 lateralAngle = -lateralAngle
470 end
471 end
472 -- Turn shoulder to point to mouse
473 shoulder.C0 = CFrame.new(1,0.5,0) * CFrame.Angles(math.pi/2 - angle,math.pi/2 + lateralAngle,0)
474 -- If not sitting then aim torso laterally towards mouse
475 if not amISitting(player.Character) then
476 torso.CFrame = CFrame.new(torso.Position, torso.Position + (Vector3.new(
477 mousePosition.X, torso.Position.Y, mousePosition.Z)-torso.Position).unit)
478 end
479 end
480end
481-- Function to bind to render stepped if player is on PC
482local function pcFrame()
483 frame(mouse.Hit.p)
484end
485
486-- Function to bind to touch moved if player is on mobile
487local function mobileFrame(touch, processed)
488 -- Check to see if the touch was on a UI element. If so, we don't want to update anything
489 if not processed then
490 -- Calculate touch position in world space. Uses Stravant's ScreenSpace Module script
491 -- to create a ray from the camera.
492 local test = screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y, 1)
493 local nearPos = game.Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y, 1))
494 nearPos = game.Workspace.CurrentCamera.CoordinateFrame.p - nearPos
495 local farPos = screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y,50)
496 farPos = game.Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(farPos) * -1
497 if farPos.magnitude > 900 then
498 farPos = farPos.unit * 900
499 end
500 local ray = Ray.new(nearPos, farPos)
501 local part, pos = game.Workspace:FindPartOnRay(ray, player.Character)
502
503 -- if a position was found on the ray then update the character's rotation
504 if pos then
505 frame(pos)
506 end
507 end
508end
509local function OnActivated()
510 local myModel = player.Character
511 if Tool.Enabled and myModel and myModel:FindFirstChild('Humanoid') and myModel.Humanoid.Health > 0 then
512 Tool.Enabled = false
513 game.ReplicatedStorage.ROBLOX_RocketFireEvent:FireServer(mouse.Hit.p)
514 wait(2)
515 Tool.Enabled = true
516 end
517end
518local oldIcon = nil
519-- Function to bind to equip event
520local function equip()
521 local character = player.Character
522 local humanoid = character.Humanoid
523 -- Setup joint variables
524 if humanoid.RigType == Enum.HumanoidRigType.R6 then
525 local torso = character.Torso
526 neck = torso.Neck
527 shoulder = torso["Right Shoulder"]
528 elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
529 neck = character.Head.Neck
530 shoulder = character.RightUpperArm.RightShoulder
531 end
532 oldNeckC0 = neck.C0
533 oldShoulderC0 = shoulder.C0
534 -- Remember old mouse icon and update current
535 oldIcon = mouse.Icon
536 mouse.Icon = "http://www.roblox.com/asset/?id=79658449"
537 -- Bind TouchMoved event if on mobile. Otherwise connect to renderstepped
538 if userInputService.TouchEnabled then
539 connection = userInputService.TouchMoved:connect(mobileFrame)
540 else
541 connection = render:connect(pcFrame)
542 end
543 -- Bind TouchStarted and TouchEnded. Used to determine if character should rotate
544 -- during touch input
545 userInputService.TouchStarted:connect(function(touch, processed)
546 mobileShouldTrack = not processed
547 end)
548 userInputService.TouchEnded:connect(function(touch, processed)
549 mobileShouldTrack = false
550 end)
551 -- If game uses filtering enabled then need to update server while tool is
552 -- held by character.
553 if workspace.FilteringEnabled then
554 while connection and connection.Connected do
555 wait()
556 game.ReplicatedStorage.ROBLOX_RocketUpdateEvent:FireServer(neck.C0, shoulder.C0)
557 end
558 end
559end
560-- Function to bind to Unequip event
561local function unequip()
562 if connection then connection:disconnect() end
563 mouse.Icon = oldIcon
564 neck.C0 = oldNeckC0
565 shoulder.C0 = oldShoulderC0
566end
567-- Bind tool events
568Tool.Equipped:connect(equip)
569Tool.Unequipped:connect(unequip)
570Tool.Activated:connect(OnActivated)
571end))
572LocalScript.Parent = RocketLauncher
573Configurations.Name = "Configurations"
574Configurations.Parent = RocketLauncher
575AttackCooldown.Value = 3
576AttackCooldown.Name = "AttackCooldown"
577AttackCooldown.Parent = Configurations
578Damage.Value = 60
579Damage.Name = "Damage"
580Damage.Parent = Configurations
581ReloadTime.Value = 1
582ReloadTime.Name = "ReloadTime"
583ReloadTime.Parent = Configurations
584BlatForce.Value = 1000
585BlastForce.Name = "BlastForce"
586BlastForce.Parent = Configurations
587BlastRadius.Value = 8
588BlastRadius.Name = "BlastRadius"
589BlastRadius.Parent = Configurations
590RocketSpeed.Value = 60
591RocketSpeed.Name = "RocketSpeed"
592RocketSpeed.Parent = Configurations
593table.insert(functions,sandbox(ScreenSpace,function()
594local PlayerMouse = Game:GetService('Players').LocalPlayer:GetMouse()
595local ScreenSpace = {}
596-- Getter functions, with a couple of hacks for Ipad pre-focus.
597function ScreenSpace.ViewSizeX()
598 local x = PlayerMouse.ViewSizeX
599 local y = PlayerMouse.ViewSizeY
600 if x == 0 then
601 return 1024
602 else
603 if x > y then
604 return x
605 else
606 return y
607 end
608 end
609end
610function ScreenSpace.ViewSizeY()
611 local x = PlayerMouse.ViewSizeX
612 local y = PlayerMouse.ViewSizeY
613 if y == 0 then
614 return 768
615 else
616 if x > y then
617 return y
618 else
619 return x
620 end
621 end
622end
623-- Nice getter for aspect ratio. Due to the checks in the ViewSize functions this
624-- will never fail with a divide by zero error.
625function ScreenSpace.AspectRatio()
626 return ScreenSpace.ViewSizeX() / ScreenSpace.ViewSizeY()
627end
628-- WorldSpace -> ScreenSpace. Raw function taking a world position and giving you the
629-- screen position.
630function ScreenSpace.WorldToScreen(at)
631 local point = Workspace.CurrentCamera.CoordinateFrame:pointToObjectSpace(at)
632 local aspectRatio = ScreenSpace.AspectRatio()
633 local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
634 local wfactor = aspectRatio*hfactor
635 --
636 local x = (point.x/point.z) / -wfactor
637 local y = (point.y/point.z) / hfactor
638 --
639 return Vector2.new(ScreenSpace.ViewSizeX()*(0.5 + 0.5*x), ScreenSpace.ViewSizeY()*(0.5 + 0.5*y))
640end
641-- ScreenSpace -> WorldSpace. Raw function taking a screen position and a depth and
642-- converting it into a world position.
643function ScreenSpace.ScreenToWorld(x, y, depth)
644 local aspectRatio = ScreenSpace.AspectRatio()
645 local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
646 local wfactor = aspectRatio*hfactor
647 --
648 local xf, yf = x/ScreenSpace.ViewSizeX()*2 - 1, y/ScreenSpace.ViewSizeY()*2 - 1
649 local xpos = xf * -wfactor * depth
650 local ypos = yf * hfactor * depth
651 --
652 return Vector3.new(xpos, ypos, depth)
653end
654-- ScreenSize -> WorldSize
655function ScreenSpace.ScreenWidthToWorldWidth(screenWidth, depth)
656 local aspectRatio = ScreenSpace.AspectRatio()
657 local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
658 local wfactor = aspectRatio*hfactor
659 local sx = ScreenSpace.ViewSizeX()
660 --
661 return -(screenWidth / sx) * 2 * wfactor * depth
662end
663function ScreenSpace.ScreenHeightToWorldHeight(screenHeight, depth)
664 local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
665 local sy = ScreenSpace.ViewSizeY()
666 --
667 return -(screenHeight / sy) * 2 * hfactor * depth
668end
669-- WorldSize -> ScreenSize
670function ScreenSpace.WorldWidthToScreenWidth(worldWidth, depth)
671 local aspectRatio = ScreenSpace.AspectRatio()
672 local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
673 local wfactor = aspectRatio*hfactor
674 local sx = ScreenSpace.ViewSizeX()
675 --
676 return -(worldWidth * sx) / (2 * wfactor * depth)
677end
678function ScreenSpace.WorldHeightToScreenHeight(worldHeight, depth)
679 local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
680 local sy = ScreenSpace.ViewSizeY()
681 --
682 return -(worldHeight * sy) / (2 * hfactor * depth)
683end
684-- WorldSize + ScreenSize -> Depth needed
685function ScreenSpace.GetDepthForWidth(screenWidth, worldWidth)
686 local aspectRatio = ScreenSpace.AspectRatio()
687 local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
688 local wfactor = aspectRatio*hfactor
689 local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
690 --
691 return -(sx * worldWidth) / (screenWidth * 2 * wfactor)
692end
693function ScreenSpace.GetDepthForHeight(screenHeight, worldHeight)
694 local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
695 local sy = ScreenSpace.ViewSizeY()
696 --
697 return -(sy * worldHeight) / (screenHeight * 2 * hfactor)
698end
699-- ScreenSpace -> WorldSpace. Taking a screen height, and a depth to put an object
700-- at, and returning a size of how big that object has to be to appear that size
701-- at that depth.
702function ScreenSpace.ScreenToWorldByHeightDepth(x, y, screenHeight, depth)
703 local aspectRatio = ScreenSpace.AspectRatio()
704 local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
705 local wfactor = aspectRatio*hfactor
706 local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
707 --
708 local worldHeight = -(screenHeight/sy) * 2 * hfactor * depth
709 --
710 local xf, yf = x/sx*2 - 1, y/sy*2 - 1
711 local xpos = xf * -wfactor * depth
712 local ypos = yf * hfactor * depth
713 --
714 return Vector3.new(xpos, ypos, depth), worldHeight
715end
716-- ScreenSpace -> WorldSpace. Taking a screen width, and a depth to put an object
717-- at, and returning a size of how big that object has to be to appear that size
718-- at that depth.
719function ScreenSpace.ScreenToWorldByWidthDepth(x, y, screenWidth, depth)
720 local aspectRatio = ScreenSpace.AspectRatio()
721 local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
722 local wfactor = aspectRatio*hfactor
723 local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
724 --
725 local worldWidth = (screenWidth/sx) * 2 * -wfactor * depth
726 --
727 local xf, yf = x/sx*2 - 1, y/sy*2 - 1
728 local xpos = xf * -wfactor * depth
729 local ypos = yf * hfactor * depth
730 --
731 return Vector3.new(xpos, ypos, depth), worldWidth
732end
733-- ScreenSpace -> WorldSpace. Taking a screen height that you want that object to be
734-- and a world height that is the size of that object, and returning the position to
735-- put that object at to satisfy those.
736function ScreenSpace.ScreenToWorldByHeight(x, y, screenHeight, worldHeight)
737 local aspectRatio = ScreenSpace.AspectRatio()
738 local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
739 local wfactor = aspectRatio*hfactor
740 local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
741 --
742 local depth = - (sy * worldHeight) / (screenHeight * 2 * hfactor)
743 --
744 local xf, yf = x/sx*2 - 1, y/sy*2 - 1
745 local xpos = xf * -wfactor * depth
746 local ypos = yf * hfactor * depth
747 --
748 return Vector3.new(xpos, ypos, depth)
749end
750-- ScreenSpace -> WorldSpace. Taking a screen width that you want that object to be
751-- and a world width that is the size of that object, and returning the position to
752-- put that object at to satisfy those.
753function ScreenSpace.ScreenToWorldByWidth(x, y, screenWidth, worldWidth)
754 local aspectRatio = ScreenSpace.AspectRatio()
755 local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
756 local wfactor = aspectRatio*hfactor
757 local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
758 --
759 local depth = - (sx * worldWidth) / (screenWidth * 2 * wfactor)
760 --
761 local xf, yf = x/sx*2 - 1, y/sy*2 - 1
762 local xpos = xf * -wfactor * depth
763 local ypos = yf * hfactor * depth
764 --
765 return Vector3.new(xpos, ypos, depth)
766end
767return ScreenSpace
768end))
769ScreenSpace.Name = "ScreenSpace"
770ScreenSpace.Parent = RocketLauncher
771for i,v in ipairs(functions) do
772 spawn(function()
773 pcall(v)
774 end)
775end
776for i,v in ipairs(mas:GetChildren()) do
777 v.Parent = workspace
778end
779mas:Destroy()