Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --https://github.com/Mokiros/roblox-FE-compatibility
- if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
- local Player,game,owner = owner,game
- local RealPlayer = Player
- do
- print("FE Compatibility code V2 by Mokiros")
- local RealPlayer = RealPlayer
- script.Parent = RealPlayer.Character
- --Fake event to make stuff like Mouse.KeyDown work
- local Disconnect_Function = function(this)
- this[1].Functions[this[2]] = nil
- end
- local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
- local FakeEvent_Metatable = {__index={
- Connect = function(this,f)
- local i = tostring(math.random(0,10000))
- while this.Functions[i] do
- i = tostring(math.random(0,10000))
- end
- this.Functions[i] = f
- return setmetatable({this,i},Disconnect_Metatable)
- end
- }}
- FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
- local function fakeEvent()
- return setmetatable({Functions={}},FakeEvent_Metatable)
- end
- --Creating fake input objects with fake variables
- local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
- FakeMouse.keyUp = FakeMouse.KeyUp
- FakeMouse.keyDown = FakeMouse.KeyDown
- local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
- local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
- CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
- end}
- --Merged 2 functions into one by checking amount of arguments
- CAS.UnbindAction = CAS.BindAction
- --This function will trigger the events that have been :Connect()'ed
- local function TriggerEvent(self,ev,...)
- for _,f in pairs(self[ev].Functions) do
- f(...)
- end
- end
- FakeMouse.TriggerEvent = TriggerEvent
- UIS.TriggerEvent = TriggerEvent
- --Client communication
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event"
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=RealPlayer then return end
- FakeMouse.Target = io.Target
- FakeMouse.Hit = io.Hit
- if not io.isMouse then
- local b = io.UserInputState == Enum.UserInputState.Begin
- if io.UserInputType == Enum.UserInputType.MouseButton1 then
- return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
- end
- if io.UserInputType == Enum.UserInputType.MouseButton2 then
- return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
- end
- for _,t in pairs(CAS.Actions) do
- for _,k in pairs(t.Keys) do
- if k==io.KeyCode then
- t.Function(t.Name,io.UserInputState,io)
- end
- end
- end
- FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
- UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
- end
- end)
- Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
- local Mouse = owner:GetMouse()
- local UIS = game:GetService("UserInputService")
- local input = function(io,RobloxHandled)
- if RobloxHandled then return end
- --Since InputObject is a client-side instance, we create and pass table instead
- Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
- end
- UIS.InputBegan:Connect(input)
- UIS.InputEnded:Connect(input)
- local h,t
- --Give the server mouse data every second frame, but only if the values changed
- --If player is not moving their mouse, client won't fire events
- local HB = game:GetService("RunService").Heartbeat
- while true do
- if h~=Mouse.Hit or t~=Mouse.Target then
- h,t=Mouse.Hit,Mouse.Target
- Event:FireServer({isMouse=true,Target=t,Hit=h})
- end
- --Wait 2 frames
- for i=1,2 do
- HB:Wait()
- end
- end]==],script)
- ----Sandboxed game object that allows the usage of client-side methods and services
- --Real game object
- local RealGame = game
- --Metatable for fake service
- local FakeService_Metatable = {
- __index = function(self,k)
- local s = rawget(self,"_RealService")
- if s then
- return typeof(s[k])=="function"
- and function(_,...)return s[k](s,...)end or s[k]
- end
- end,
- __newindex = function(self,k,v)
- local s = rawget(self,"_RealService")
- if s then s[k]=v end
- end
- }
- local function FakeService(t,RealService)
- t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
- return setmetatable(t,FakeService_Metatable)
- end
- --Fake game object
- local FakeGame = {
- GetService = function(self,s)
- return rawget(self,s) or RealGame:GetService(s)
- end,
- Players = FakeService({
- LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
- },"Players"),
- UserInputService = FakeService(UIS,"UserInputService"),
- ContextActionService = FakeService(CAS,"ContextActionService"),
- RunService = FakeService({
- _btrs = {},
- RenderStepped = RealGame:GetService("RunService").Heartbeat,
- BindToRenderStep = function(self,name,_,fun)
- self._btrs[name] = self.Heartbeat:Connect(fun)
- end,
- UnbindFromRenderStep = function(self,name)
- self._btrs[name]:Disconnect()
- end,
- },"RunService")
- }
- rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
- FakeGame.service = FakeGame.GetService
- FakeService(FakeGame,game)
- --Changing owner to fake player object to support owner:GetMouse()
- game,owner = FakeGame,FakeGame.Players.LocalPlayer
- end
- size = 240
- CA = CFrame.Angles
- CN = CFrame.new
- V3 = Vector3.new
- MR = math.rad
- MP = math.pi
- MRA = math.random
- MH = math.huge
- Wood = {"Brown", "Reddish brown"}
- Leaves = {"Earth green", "Bright green", "Dark green", "Camo"}
- LeafMeshes = {{"http://www.roblox.com/asset/?id=16659363", V3(2.05,-1.6,2.05)},
- {"http://www.roblox.com/asset/?id=1091940", V3(1.2,0.6,1.2)}}
- Rock = {"Medium grey", "Dark grey"}
- Add = {
- Mesh = function(P, Id, Id2, scale)
- local m = Instance.new("SpecialMesh", P)
- m.Scale = scale
- m.MeshId = Id
- m.TextureId = Id2
- end
- }
- function Part(P, Anch, Coll, Tran, Ref, Col, X, Y, Z)
- local p = Instance.new("Part")
- p.TopSurface = 0
- p.BottomSurface = 0
- p.Transparency = Tran
- p.Reflectance = Ref
- p.CanCollide = Coll
- p.Anchored = Anch
- p.BrickColor = BrickColor.new(Col)
- p.formFactor = "Custom"
- p.Size = V3(X,Y,Z)
- p.Parent = P
- p.Locked = true
- p:BreakJoints()
- return p
- end
- Mod = Instance.new("Model",workspace)
- Mod.Name = "Jungle"
- Models = {
- function(cf, siz)
- local m = Instance.new("Model",Mod)
- local cen = cf * CN(0, 0, -38*siz)
- local wo = Wood[MRA(1,#Wood)]
- local le = Leaves[MRA(1,#Leaves)]
- local last = nil
- for i = 0, 1, 0.2 do
- local p = Part(m, true, true, 0, 0, wo, 3*siz, 5.7*siz, 3*siz)
- Instance.new("SpecialMesh",p)
- p.CFrame = cen * CA(MR(-40*i), 0, 0) * CN(0, 0, 38*siz)
- if wo == Wood[1] then wo = Wood[2] else wo = Wood[1] end
- last = p
- end
- local messa = LeafMeshes[MRA(1,#LeafMeshes)]
- local a = -3
- if messa == LeafMeshes[1] then
- a = 0.4
- end
- last.BrickColor = BrickColor.new(le)
- local p = Part(m, true, false, 0, 0, le, 0.2, 0.2, 0.2)
- local m = Add.Mesh(p, messa[1], "", V3((messa[2].X*10)*siz,(messa[2].Y*10)*siz,(messa[2].Z*10)*siz))
- p.CFrame = last.CFrame * CN(0, a*siz, 0) * CA(MP+MR(20), 0, 0)
- end,
- function(cf, siz)
- local m = Instance.new("Model",Mod)
- local ro1, ro2 = Rock[MRA(1,#Rock)], Rock[MRA(1,#Rock)]
- local p = Part(m, true, true, 0, 0, ro1, 7.5*siz, 7.5*siz, 7.5*siz)
- p.CFrame = cf * CN(0, 1.8*siz, 4*siz) * CA(MR(MRA(-180,180)), MR(MRA(-180,180)), MR(MRA(-180,180)))
- local ms = Add.Mesh(p, "http://www.roblox.com/asset/?id=1290033", "", V3(5*siz, 5*siz, 5*siz))
- local p2 = Part(m, true, true, 0, 0, ro2, 5.5*siz, 5.5*siz, 5.5*siz)
- p2.CFrame = cf * CN(7*siz, 1.5*siz, -6*siz) * CA(MR(MRA(-180,180)), MR(MRA(-180,180)), MR(MRA(-180,180)))
- local ms2 = Add.Mesh(p2, "http://www.roblox.com/asset/?id=1290033", "", V3(3.8*siz, 3.8*siz, 3.8*siz))
- end,
- function(cf, siz)
- local m = Instance.new("Model",Mod)
- local le = Leaves[MRA(1,#Leaves)]
- local p = Part(m, true, false, 0, 0, le, 0.2, 0.2, 0.2)
- p.CFrame = cf * CN(2*siz, 1.6*siz, -4*siz) * CA(0, 0, 0)
- local ms = Add.Mesh(p, "http://www.roblox.com/asset/?id=1095708", "", V3(12*siz, 11*siz, 10*siz))
- local p2 = Part(m, true, false, 0, 0, le, 0.2, 0.2, 0.2)
- p2.CFrame = cf * CN(-4*siz, 1.1*siz, -1*siz) * CA(0, MR(-34), 0)
- local ms2 = Add.Mesh(p2, "http://www.roblox.com/asset/?id=1095708", "", V3(10*siz, 7.5*siz, 8*siz))
- end,
- function(cf, siz)
- local m = Instance.new("Model",Mod)
- local p = Part(m, true, false, 0, 0, "Bright green", 0.2, 0.2, 0.2)
- p.CFrame = cf * CN(2*siz, 1.1*siz, -4*siz) * CA(0, 0, 0)
- local ms = Add.Mesh(p, "http://www.roblox.com/asset/?id=16659363", "http://www.roblox.com/asset/?id=16659355", V3(10*siz, 14*siz, 10*siz))
- local p2 = Part(m, true, false, 0, 0, "Bright green", 0.2, 0.2, 0.2)
- p2.CFrame = cf * CN(-4*siz, 0.7*siz, 1*siz) * CA(MR(MRA(-15,15)), MR(MRA(-180,180)), MR(MRA(-15,15)))
- local ms2 = Add.Mesh(p2, "http://www.roblox.com/asset/?id=16659363", "http://www.roblox.com/asset/?id=16659355", V3(7*siz, 11*siz, 6*siz))
- end,
- function(cf, siz)
- local m = Instance.new("Model",Mod)
- local p = Part(m, true, true, 0, 0, "White", 1.2*siz, 6*siz, 1.2*siz)
- p.CFrame = cf * CN((MRA(-4*100,4*100)/100)*siz, 3.2*siz, (MRA(-4*100,4*100)/100)*siz) * CA(0, MR(MRA(-180,180)), 0)
- local ms = Add.Mesh(p, "http://www.roblox.com/asset/?id=1090398", "http://www.roblox.com/asset/?id=1090399", V3(3.5*siz, 5*siz, 3.5*siz))
- end,
- function(cf, siz)
- local m = Instance.new("Model",Mod)
- local col = Wood[MRA(1,#Wood)]
- local p = Part(m, true, true, 0, 0, col, 2.8*siz, 22*siz, 2.8*siz)
- Instance.new("SpecialMesh",p)
- p.CFrame = cf * CN((MRA(-4*100,4*100)/100)*siz, 11*siz, (MRA(-4*100,4*100)/100)*siz) * CA(0, MR(MRA(-180,180)), 0)
- local leave = Leaves[MRA(1, #Leaves)]
- local mes = LeafMeshes[MRA(1, #LeafMeshes)]
- local a = 3
- local ca = CA(MR(MRA(-30, 30)), MR(MRA(-180, 180)), MR(MRA(-30, 30)))
- if mes == LeafMeshes[1] then
- a = -0.5
- ca = ca * CA(MP, 0, 0)
- end
- for i = 1, MRA(1,5) do
- local cf2 = p.CFrame * CA(0, MR(MRA(-180,180)), 0) * CN(0, (MRA(2*100, 14*100)/100)*siz, -1.4*siz)
- local center = cf2 * CN(0, 0, -8*siz) * CA(0, 0, 0)
- local first = nil
- for x = 0, 45, 15 do
- local p2 = Part(m, true, true, 0, 0, col, 2.5*siz, 4*siz, 2.5*siz)
- Instance.new("SpecialMesh", p2)
- p2.CFrame = center * CN(0, 0, 4*siz) * CA(MR(x), 0, 0) * CN(0, 0, 10*siz) * CA(0, 0, 0)
- if first == nil then first = p2 end
- end
- local p3 = Part(m, true, false, 0, 0, leave, 0.2, 0.2, 0.2)
- Add.Mesh(p3, mes[1], "", (mes[2]*7)*siz)
- local ca2 = CA(MR(MRA(-30, 30)), MR(MRA(-180, 180)), MR(MRA(-30, 30)))
- if mes == LeafMeshes[1] then
- ca2 = ca2 * CA(MP, 0, 0)
- end
- p3.CFrame = first.CFrame * CN(0, a*siz, 0) * ca2
- end
- local p3 = Part(m, true, false, 0, 0, leave, 0.2, 0.2, 0.2)
- Add.Mesh(p3, mes[1], "", (mes[2]*9)*siz)
- local cn = p.CFrame * CN(0, 11*siz, 0)
- p3.CFrame = cn * CN(0, a*siz, 0) * ca
- end,
- }
- pos = CN(0, 0, 0)
- local base = Part(Mod, true, true, 0, 0, Leaves[MRA(1,#Leaves)], size, 1, size)
- base.CFrame = pos * CN(0, 1, 0)
- base.Material = "Grass"
- for x = -size/2, size/2, 20 do
- for z = -size/2, size/2, 20 do
- Models[MRA(1, #Models)](pos * CN(x+(MRA(-4*1000, 4*1000)/1000), 1.2, z+(MRA(-4*1000, 4*1000)/1000)) * CA(0, MR(MRA(-180,180)), 0), MRA(1.1*100, 2.4*100)/100)
- end
- wait(0.2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement