Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Server Side
- local players = game:GetService("Players")
- local rep = game:GetService("ReplicatedStorage")
- local PlayersFolder = workspace:FindFirstChild("Players")
- if not PlayersFolder then
- PlayersFolder = Instance.new("Folder")
- PlayersFolder.Name = "Players"
- PlayersFolder.Parent = workspace
- end
- game.Players.PlayerAdded:Connect(function(player)
- player.CharacterAdded:Connect(function(character)
- local playerFolder = PlayersFolder:FindFirstChild(player.Name)
- if not playerFolder then
- playerFolder = Instance.new("Folder")
- playerFolder.Name = player.Name
- playerFolder.Parent = PlayersFolder
- local inventory = Instance.new("Folder")
- inventory.Name = "Inventory"
- inventory.Parent = playerFolder
- end
- character.Parent = playerFolder
- character:WaitForChild("Humanoid").Died:Connect(function()
- player.CharacterAdded:Wait().Parent = playerFolder
- end)
- end)
- end)
- local cd = {}
- rep.Items.OnServerEvent:Connect(function(player, status)
- local char = player.Character
- local inventory = game.Workspace.Players[player.Name].Inventory
- if char then
- if status == "Insert" and not table.find(cd, player) then
- local Lantern = rep.Lantern.Lantern:Clone()
- local motor6 = rep.Lantern.Handle:Clone()
- motor6.Part0 = char["Right Arm"]
- motor6.Part1 = Lantern.Handle
- motor6.Parent = char["Right Arm"]
- Lantern.Parent = inventory
- rep.Animation:FireClient(player, "Lantern", "Equip")
- elseif status == "Remove" then
- table.insert(cd, player)
- task.delay(0.5,function()
- table.remove(cd, table.find(cd, player))
- end)
- if char["Right Arm"]:FindFirstChild("Handle1") then
- char["Right Arm"].Handle:Destroy()
- end
- inventory.Lantern:Destroy()
- rep.Animation:FireClient(player, "Lantern", "UnEquip")
- elseif table.find(cd, player) then
- rep.Notifications:FireClient(player, "⚠️ Please wait a moment after unequiping the item.", "Warn")
- end
- end
- end)
- --------------------------------------------------------------------------------------------------------------------------------
- -- Client Side
- local UIS = game:GetService("UserInputService")
- local rep = game:GetService("ReplicatedStorage")
- local player = game.Players.LocalPlayer
- local char = player.Character
- local animator: Animator = char:WaitForChild("Humanoid"):WaitForChild("Animator")
- local notifications = require(player.PlayerGui.NotificationSystem.NotificationModule)
- local HoldLantern = animator:LoadAnimation(rep.Animations.Tools.HoldItem)
- local OpenLantern = animator:LoadAnimation(rep.Animations.Tools.LanternOpen)
- UIS.InputBegan:Connect(function(key,gpe)
- if gpe then return end
- if key.KeyCode == Enum.KeyCode.B then
- if workspace.Players[player.Name].Inventory:FindFirstChild("Lantern") then
- rep.Items:FireServer("Remove")
- else
- rep.Items:FireServer("Insert")
- end
- end
- end)
- rep.Animation.OnClientEvent:Connect(function(Tool, Status)
- if Status == "Equip" then
- if Tool == "Lantern" then
- OpenLantern:Play()
- HoldLantern:Play()
- end
- elseif Status == "UnEquip" then
- if Tool == "Lantern" then
- HoldLantern:Stop()
- OpenLantern:Stop()
- end
- end
- end)
- rep.Notifications.OnClientEvent:Connect(function(Text, Status)
- if Status == "Warn" then
- notifications.NewWarning(Text, 1)
- elseif Status == "Success" then
- notifications.NewSucess(Text, 1)
- elseif Status == "Error" then
- notifications.NewError(Text, 1)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement