Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 by Mokiros")
- local rp = RealPlayer
- script.Parent = rp.Character
- --RemoteEvent for communicating
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event"
- --Fake event to make stuff like Mouse.KeyDown work
- local function fakeEvent()
- local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
- t.connect = t.Connect
- return t
- end
- --Creating fake input objects with fake variables
- local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
- 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 te(self,ev,...)
- local t = m[ev]
- if t and t._fakeEvent then
- for _,f in pairs(t.Functions) do
- f(...)
- end
- end
- end
- m.TrigEvent = te
- UIS.TrigEvent = te
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=rp then return end
- m.Target = io.Target
- m.Hit = io.Hit
- if not io.isMouse then
- local b = io.UserInputState == Enum.UserInputState.Begin
- if io.UserInputType == Enum.UserInputType.MouseButton1 then
- return m:TrigEvent(b and "Button1Down" or "Button1Up")
- end
- if io.UserInputType == Enum.UserInputType.MouseButton2 then
- return m:TrigEvent(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
- m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
- UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
- end
- end)
- Event.Parent = NLS([==[
- local Player = game:GetService("Players").LocalPlayer
- local Event = script:WaitForChild("UserInput_Event")
- local Mouse = Player:GetMouse()
- local UIS = game:GetService("UserInputService")
- local input = function(io,a)
- if a 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 30 times every second, but only if the values changed
- --If player is not moving their mouse, client won't fire events
- while wait(1/30) 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
- end]==],Player.Character)
- ----Sandboxed game object that allows the usage of client-side methods and services
- --Real game object
- local _rg = game
- --Metatable for fake service
- local fsmt = {
- __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 _rg:GetService(RealService) or RealService
- return setmetatable(t,fsmt)
- end
- --Fake game object
- local g = {
- GetService = function(self,s)
- return rawget(self,s) or _rg:GetService(s)
- end,
- Players = FakeService({
- LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
- },"Players"),
- UserInputService = FakeService(UIS,"UserInputService"),
- ContextActionService = FakeService(CAS,"ContextActionService"),
- RunService = FakeService({
- _btrs = {},
- RenderStepped = _rg: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(g.Players,"localPlayer",g.Players.LocalPlayer)
- g.service = g.GetService
- FakeService(g,game)
- --Changing owner to fake player object to support owner:GetMouse()
- game,owner = g,g.Players.LocalPlayer
- end
- plr = game.Players.LocalPlayer
- repeat wait() until plr.Character
- char = plr.Character
- effect = Instance.new("Model",char)
- effect.Name = "Effects"
- moozik = Instance.new("Sound",char)
- moozik.SoundId = "rbxassetid://132024343"
- moozik.Volume = 10
- moozik.Looped = true
- moozik:Play()
- hurt = Instance.new("Sound",char)
- hurt.SoundId = "rbxassetid://975173739"
- hurt.Volume = 10
- local block = Instance.new("Part",effect)
- block.Size = Vector3.new(1,1,1)
- block.CanCollide = false
- local weld = Instance.new("Weld",block)
- weld.Part0 = block
- weld.Part1 = char["Right Arm"]
- weld.C0 = CFrame.new(-0.00427627563, -0.0187358856, 1.48222256, 1, 0, 0, 0, -0.0125430031, -0.999921381, 0, 0.999921262, -0.0125430049)
- local decal1 = Instance.new("Decal",block)
- decal1.Face = "Top"
- local decal2 = Instance.new("Decal",block)
- decal2.Face = "Front"
- local decal3 = Instance.new("Decal",block)
- decal3.Face = "Bottom"
- local decal4 = Instance.new("Decal",block)
- decal4.Face = "Back"
- local decal5 = Instance.new("Decal",block)
- decal5.Face = "Left"
- local decal6 = Instance.new("Decal",block)
- decal6.Face = "Right"
- damaged = false
- local reddamage = function(timeofeffect)
- for i,v in pairs(char:GetChildren()) do
- if v.ClassName == "Part" and v.Name ~= "HumanoidRootPart" then
- local cp = v:Clone()
- cp.Parent = effect
- cp.BrickColor = BrickColor.new("Really red")
- cp.Transparency = 0.7
- cp.CanCollide = false
- cp.Material = Enum.Material.Neon
- if cp.Name == "Head" then
- cp.face:Destroy()
- end
- if cp.Name == "Torso" then
- cp.roblox:Destroy()
- end
- if v ~= char.Head then
- cp.Size = v.Size+(Vector3.new(1,1,1)*0.2)
- else
- cp.Size = (Vector3.new(1,1,1)*v.Size.Y)+(Vector3.new(1,1,1)*0.2)
- end
- local weld = Instance.new("Weld",cp)
- weld.Part0 = v
- weld.Part1 = cp
- game:GetService("Debris"):AddItem(cp,timeofeffect)
- end
- end
- char.Torso.Velocity = char.Torso.CFrame.lookVector * -100
- hurt:Play()
- end
- function changeyourblockdecal(bottom,top,left,right,back,front)
- decal3.Texture = bottom
- decal1.Texture = top
- decal5.Texture = left
- decal6.Texture = right
- decal4.Texture = back
- decal2.Texture = front
- end
- function changeblockdecal(whatblock , bottom,top,left,right,back,front)
- local tex1 = Instance.new("Decal",whatblock)
- tex1.Face = "Top"
- local tex2 = Instance.new("Decal",whatblock)
- tex2.Face = "Front"
- local tex3 = Instance.new("Decal",whatblock)
- tex3.Face = "Bottom"
- local tex4 = Instance.new("Decal",whatblock)
- tex4.Face = "Back"
- local tex5 = Instance.new("Decal",whatblock)
- tex5.Face = "Left"
- local tex6 = Instance.new("Decal",whatblock)
- tex6.Face = "Right"
- tex3.Texture = bottom
- tex1.Texture = top
- tex5.Texture = left
- tex6.Texture = right
- tex4.Texture = back
- tex2.Texture = front
- end
- lhand = char.Torso["Left Shoulder"]:Clone()
- rhand = char.Torso["Right Shoulder"]:Clone()
- local rhandweld = Instance.new("Weld",char)
- rhandweld.Part0 = char.Torso
- rhandweld.Part1 = char["Right Arm"]
- rhandweld.C0 = CFrame.new(1.5, 0, 0, 1, -1.6395192e-43, 0, -1.6395192e-43, 1, 0, 0, 0, 1)
- local human2 = Instance.new("Weld",char)
- human2.Part0 = char.HumanoidRootPart
- human2.Part1 = char.Torso
- human2co = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- function changeblocktype(whattype)
- if whattype == "Grass" then
- changeyourblockdecal("http://www.roblox.com/asset/?id=96167755","http://www.roblox.com/asset/?id=96430265","http://www.roblox.com/asset/?id=96430337","http://www.roblox.com/asset/?id=96430337","http://www.roblox.com/asset/?id=96430337","http://www.roblox.com/asset/?id=96430337")
- end
- if whattype == "Dirt" then
- changeyourblockdecal("http://www.roblox.com/asset/?id=96167755","http://www.roblox.com/asset/?id=96167755","http://www.roblox.com/asset/?id=96167755","http://www.roblox.com/asset/?id=96167755","http://www.roblox.com/asset/?id=96167755","http://www.roblox.com/asset/?id=96167755")
- end
- if whattype == "Cobblestone" then
- changeyourblockdecal("http://www.roblox.com/asset/?id=57539377","http://www.roblox.com/asset/?id=57539377","http://www.roblox.com/asset/?id=57539377","http://www.roblox.com/asset/?id=57539377","http://www.roblox.com/asset/?id=57539377","http://www.roblox.com/asset/?id=57539377")
- end
- if whattype == "Gold" then
- changeyourblockdecal("http://www.roblox.com/asset/?id=71405851","http://www.roblox.com/asset/?id=71405851","http://www.roblox.com/asset/?id=71405851","http://www.roblox.com/asset/?id=71405851","http://www.roblox.com/asset/?id=71405851","http://www.roblox.com/asset/?id=71405851")
- end
- if whattype == "Stone" then
- changeyourblockdecal("http://www.roblox.com/asset/?id=56882261","http://www.roblox.com/asset/?id=56882261","http://www.roblox.com/asset/?id=56882261","http://www.roblox.com/asset/?id=56882261","http://www.roblox.com/asset/?id=56882261","http://www.roblox.com/asset/?id=56882261")
- end
- if whattype == "DiamondBlock" then
- changeyourblockdecal("http://www.roblox.com/asset/?id=59262371","http://www.roblox.com/asset/?id=59262371","http://www.roblox.com/asset/?id=59262371","http://www.roblox.com/asset/?id=59262371","http://www.roblox.com/asset/?id=59262371","http://www.roblox.com/asset/?id=59262371")
- end
- if whattype == "DiamondOre" then
- changeyourblockdecal("http://www.roblox.com/asset/?id=49919647","http://www.roblox.com/asset/?id=49919647","http://www.roblox.com/asset/?id=49919647","http://www.roblox.com/asset/?id=49919647","http://www.roblox.com/asset/?id=49919647","http://www.roblox.com/asset/?id=49919647")
- end
- if whattype == "WoodenPlank" then
- changeyourblockdecal("http://www.roblox.com/asset/?id=107806036","http://www.roblox.com/asset/?id=107806036","http://www.roblox.com/asset/?id=107806036","http://www.roblox.com/asset/?id=107806036","http://www.roblox.com/asset/?id=107806036","http://www.roblox.com/asset/?id=107806036")
- end
- if whattype == "OakWood" then
- changeyourblockdecal("http://www.roblox.com/asset/?id=55355773","http://www.roblox.com/asset/?id=55355773","http://www.roblox.com/asset/?id=55319786","http://www.roblox.com/asset/?id=55319786","http://www.roblox.com/asset/?id=55319786","http://www.roblox.com/asset/?id=55319786")
- end
- if whattype == "GoldOre" then
- changeyourblockdecal("http://www.roblox.com/asset/?id=73374646","http://www.roblox.com/asset/?id=73374646","http://www.roblox.com/asset/?id=73374646","http://www.roblox.com/asset/?id=73374646","http://www.roblox.com/asset/?id=73374646","http://www.roblox.com/asset/?id=73374646")
- end
- if whattype == "Sponge" then
- changeyourblockdecal("http://www.roblox.com/asset/?id=38945383","http://www.roblox.com/asset/?id=38945383","http://www.roblox.com/asset/?id=38945383","http://www.roblox.com/asset/?id=38945383","http://www.roblox.com/asset/?id=38945383","http://www.roblox.com/asset/?id=38945383")
- end
- end
- changeblocktype("Grass")
- function playanim(whatanim,speed)
- if whatanim == "Place" then
- rhandweld.Parent = char.Torso
- for i = 0,1, speed do
- rhandweld.C0 = rhandweld.C0:lerp(CFrame.new(1.5, 0.473864555, -0.788700104, 1, 0, 0, 0, -0.0214149933, -0.999770641, 0, 0.999770641, -0.0214149933),i)
- game:GetService("RunService").RenderStepped:wait()
- end
- for i = 0,1, speed do
- rhandweld.C0 = rhandweld.C0:lerp(CFrame.new(0.957962036, 0.0477108955, -1.06759644, 0.445479125, 0.728770554, 0.520040333, 0.0191690028, 0.572963655, -0.81935662, -0.895087242, 0.374974847, 0.241273522),i)
- game:GetService("RunService").RenderStepped:wait()
- end
- end
- if whatanim == "Destroy" then
- rhandweld.Parent = char.Torso
- for i = 0,1, speed do
- rhandweld.C0 = rhandweld.C0:lerp(CFrame.new(1.5, 0.473864555, -0.788700104, 1, 0, 0, 0, -0.0214149933, -0.999770641, 0, 0.999770641, -0.0214149933),i)
- game:GetService("RunService").RenderStepped:wait()
- end
- for i = 0,1, speed do
- rhandweld.C0 = rhandweld.C0:lerp(CFrame.new(0.957962036, 0.0477108955, -1.06759644, 0.445479125, 0.728770554, 0.520040333, 0.0191690028, 0.572963655, -0.81935662, -0.895087242, 0.374974847, 0.241273522),i)
- game:GetService("RunService").RenderStepped:wait()
- end
- end
- if whatanim == "NormalPose" then
- for i = 0,1 , speed do
- rhandweld.C0 = rhandweld.C0:lerp(CFrame.new(1.5, 0, 0, 1, -1.6395192e-43, 0, -1.6395192e-43, 1, 0, 0, 0, 1),i)
- game:GetService("RunService").RenderStepped:wait()
- end
- end
- end
- canuse = true
- mouse = plr:GetMouse()
- function buildblock()
- if canuse then
- canuse = false
- playanim("Place", 0.07)
- local theactualblock = Instance.new("Part")
- theactualblock:BreakJoints()
- theactualblock.Parent = workspace
- theactualblock.Transparency = 0
- theactualblock.CFrame = mouse.Hit + Vector3.new(0,1.09,0)
- theactualblock.Orientation = Vector3.new(0,0,0)
- theactualblock.Size = Vector3.new(3,3,3)
- theactualblock.Anchored = true
- theactualblock.CanCollide = true
- theactualblock.Name = "BlockPlace"
- changeblockdecal(theactualblock,decal3.Texture, decal1.Texture, decal5.Texture,decal6.Texture, decal4.Texture, decal2.Texture)
- playanim("NormalPose", 0.3)
- canuse = true
- end
- end
- function destroyblock()
- if mouse.Target.Name == "BlockPlace" and mouse.Target.Name ~= "Base" and mouse.Target.Name ~= "Baseplate" and mouse.Target.Name ~= "Workspace" then
- playanim("Destroy", 0.07)
- mouse.Target:Destroy()
- playanim("NormalPose", 0.3)
- end
- end
- local mouse1 = mouse.Button1Down:connect(function()
- buildblock()
- end)
- local mouse2 = mouse.KeyDown:connect(function(k)
- if k == "q" then
- destroyblock()
- end
- if k == "e" then
- local chance = math.random(1,11)
- if chance == 1 then
- changeblocktype("Grass")
- end
- if chance == 2 then
- changeblocktype("Dirt")
- end
- if chance == 3 then
- changeblocktype("Cobblestone")
- end
- if chance == 4 then
- changeblocktype("Gold")
- end
- if chance == 5 then
- changeblocktype("Stone")
- end
- if chance == 6 then
- changeblocktype("DiamondBlock")
- end
- if chance == 7 then
- changeblocktype("DiamondOre")
- end
- if chance == 8 then
- changeblocktype("WoodenPlank")
- end
- if chance == 9 then
- changeblocktype("OakWood")
- end
- if chance == 10 then
- changeblocktype("GoldOre")
- end
- if chance == 11 then
- changeblocktype("Sponge")
- end
- end
- end)
- HasDied = false
- Dead = false
- local reddeath = function()
- for i,v in pairs(char:GetChildren()) do
- if v.ClassName == "Part" and v.Name ~= "HumanoidRootPart" then
- local cp = v:Clone()
- cp.Parent = effect
- cp.BrickColor = BrickColor.new("Really red")
- cp.Transparency = 1
- cp.CanCollide = false
- cp.Material = Enum.Material.Neon
- if cp.Name == "Head" then
- cp.face:Destroy()
- end
- if cp.Name == "Torso" then
- cp.roblox:Destroy()
- end
- if v ~= char.Head then
- cp.Size = v.Size+(Vector3.new(1,1,1)*0.2)
- else
- cp.Size = (Vector3.new(1,1,1)*v.Size.Y)+(Vector3.new(1,1,1)*0.2)
- end
- local weld = Instance.new("Weld",cp)
- weld.Part0 = v
- weld.Part1 = cp
- end
- end
- end
- reddeath()
- generategui = function()
- local screen = Instance.new("ScreenGui",plr.PlayerGui)
- screen.Name = "Death(lol i was lazy to add buttons lol)"
- local text = Instance.new("TextLabel",screen)
- text.Text = "You died!"
- text.TextColor3 = Color3.new(1,1,1)
- text.Font = "Arcade"
- text.TextScaled = true
- text.Position = UDim2.new(0.381, 0,0.172, 0)
- text.Size = UDim2.new(0, 200, 0, 50)
- text.BackgroundTransparency = 1
- local respawn = Instance.new("TextButton",screen)
- respawn.Text = "Respawn"
- respawn.TextScaled = true
- respawn.Position = UDim2.new(0.381, 0,0.561, 0)
- respawn.Size = UDim2.new(0, 200,0, 50)
- respawn.BackgroundTransparency = 1
- respawn.TextColor3 = Color3.new(1,1,1)
- respawn.Font = "Arcade"
- respawn.MouseButton1Click:connect(function()
- Dead = false
- HasDied = false
- char.Humanoid.Health = 0
- char.Parent = nil
- respawn.Text = "Say g/r or g/sr to respawn properly"
- end)
- end
- local BODY = {}
- LeftArm = char["Left Arm"]
- RightLeg = char["Right Leg"]
- LeftLeg = char["Left Leg"]
- for _, c in pairs(char:GetDescendants()) do
- if c:IsA("BasePart") and c.Name ~= "Handle" then
- if c ~= char.HumanoidRootPart and c ~= char.Torso and c ~= char.Head and c ~= char["Right Arm"] and c ~= LeftArm and c ~= RightLeg and c ~= LeftLeg then
- c.CustomPhysicalProperties = PhysicalProperties.new(0, 0, 0, 0, 0)
- end
- table.insert(BODY,{c,c.Parent,c.Material,c.Color,c.Transparency})
- elseif c:IsA("JointInstance") then
- table.insert(BODY,{c,c.Parent,nil,nil,nil})
- end
- end
- for e = 1, #BODY do
- if BODY[e] ~= nil then
- local STUFF = BODY[e]
- local PART = STUFF[1]
- local PARENT = STUFF[2]
- local MATERIAL = STUFF[3]
- local TRANSPARENCY = STUFF[5]
- if PART.ClassName == "Part" and PART ~= char.HumanoidRootPart then
- PART.Material = MATERIAL
- PART.Transparency = TRANSPARENCY
- end
- PART.AncestryChanged:Connect(function()
- PART.Parent = PARENT
- end)
- end
- end
- function refit()
- char.Parent = workspace
- for e = 1, #BODY do
- if BODY[e] ~= nil then
- local STUFF = BODY[e]
- local PART = STUFF[1]
- local PARENT = STUFF[2]
- local MATERIAL = STUFF[3]
- local TRANSPARENCY = STUFF[5]
- if PART.ClassName == "Part" and PART ~= char.HumanoidRootPart then
- PART.Material = MATERIAL
- PART.Transparency = TRANSPARENCY
- end
- if PART.Parent ~= PARENT then
- char:FindFirstChildOfClass("Humanoid"):remove()
- PART.Parent = PARENT
- Humanoid = Instance.new("Humanoid",char)
- end
- end
- end
- end
- char.Humanoid.Died:connect(function()
- hurt:Play()
- refit()
- mouse1:Disconnect()
- mouse2:Disconnect()
- for i,v in pairs(effect:GetChildren()) do
- if v.ClassName == "Part" then
- v.Transparency = 0.7
- end
- end
- workspace.CurrentCamera.CameraSubject = char.Head
- generategui()
- HasDied = true
- Dead = true
- for i = 0,1, 0.03 do
- human2.C0 = human2.C0:lerp(CFrame.new(1.99999964, -3.00000095, 0, -0.00852799695, 0.999963641, 0, -0.999963641, -0.00852799695, 0, 0, 0, 1):inverse() + Vector3.new(0,1,0),i)
- game:GetService("RunService").RenderStepped:wait()
- end
- end)
- while true do
- game:GetService("RunService").RenderStepped:wait()
- if char.Humanoid.Health < 100 and not damaged and not Dead and not HasDied then
- reddamage(0.5)
- damaged = true
- wait(1)
- damaged = false
- char.Humanoid.Health = 100
- end
- if char.Humanoid.Health < 1 and Dead and HasDied then
- refit()
- for i,v in pairs(effect:GetChildren()) do
- if v.ClassName == "Part" then
- v.Transparency = 0.7
- end
- end
- end
- if Dead and HasDied then
- char.Humanoid.WalkSpeed = 0
- char.Humanoid.JumpPower = 0
- human2.Parent = char.Torso
- rhandweld.Parent = char.Torso
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement