https://tech5g.tistory.com/299 이전 글 참고
- gui localscript
```
local open = game.Workspace.openShop
local close = game.Workspace.closeShop
local frame = script.Parent
local closeButton = frame.closeButton
local apply1 = frame.apply1
local apply2 = frame.apply2
local apply3 = frame.apply3
local ReplacatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplacatedStorage:WaitForChild('ApplyTool')
frame.Visible = false
local function shopMenu(hit)
local player = game.Players:FindFirstChild(hit.Parent.Name)
if player and player.PlayerGui.ScreenGui.Shop.Visible == false then
--print(player)
player.PlayerGui.ScreenGui.Shop.Visible = true
player.Character.Humanoid.WalkSpeed = 0
end
end
local function closeMenu()
local player = game.Players.LocalPlayer
if player and player.PlayerGui.ScreenGui.Shop.Visible == true then
--print(player)
player.PlayerGui.ScreenGui.Shop.Visible = false
-- player.Character.HumanoidRootPart.Orientation = close.Orientation
player.Character.HumanoidRootPart.CFrame = CFrame.new(close.Position.X, close.Position.Y+3, close.Position.Z)
player.Character.Humanoid.WalkSpeed = 16
end
end
local function applyTool1()
local tool = ReplacatedStorage.ShopItems.TommyGun
remoteEvent:FireServer(tool)
end
local function applyTool2()
local tool = ReplacatedStorage.ShopItems.ClassicSword
remoteEvent:FireServer(tool)
end
local function applyTool3()
local tool = ReplacatedStorage.ShopItems.HyperGun
remoteEvent:FireServer(tool)
end
open.Touched:Connect(shopMenu)
closeButton.MouseButton1Click:Connect(closeMenu)
apply1.MouseButton1Click:Connect(applyTool1)
apply2.MouseButton1Click:Connect(applyTool2)
apply3.MouseButton1Click:Connect(applyTool3)
```
-- ServerSideScript/ApplyTool
```
local ReplacatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplacatedStorage:WaitForChild('ApplyTool')
local function applyTool(player, tool)
-- print(player.Name)
-- print(tool.Name)
if player.leaderstats.Money.Value >= tool.Price.Value then
player.leaderstats.Money.Value = player.leaderstats.Money.Value - tool.Price.Value
-- TODOS (backpack, StarterGear isn't working 21/07/29)
--[[
local giveTool = ReplacatedStorage.ShopItems[tool.Name]:Clone()
giveTool.Parent = player.BackPack
local giveTool = ReplacatedStorage.ShopItems[tool.Name]:Clone()
giveTool.Parent = player.StarterGear
]]
end
end
remoteEvent.OnServerEvent:connect(applyTool)
```
-- TODO
leaderstats 화면 표시하기
'tech > game' 카테고리의 다른 글
21/07/30 Roblox - How to make a simple roblox widget plugin (0) | 2021.07.30 |
---|---|
21/07/30 How to add GIFs in Roblox Studio (tutorial) (0) | 2021.07.30 |
21/07/28 Roblox Studio Tutorial (Script 포함) (0) | 2021.07.28 |
21/07/28 How to Make a Roblox First Person Shooter (0) | 2021.07.28 |
21/07/28 How to Make a Shop Menu GUI [Updated Version] - Roblox Studio Tutorial (0) | 2021.07.28 |