Skip to content

Commit

Permalink
Made VR chalk creation server sided
Browse files Browse the repository at this point in the history
  • Loading branch information
blinkybool committed Dec 19, 2023
1 parent f1ad09c commit d242049
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/Client/VRDrawingController/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ local FreeHand = require(root.DrawingTask.FreeHand)
local t = (require)(root.Parent.t)
local Config = require(root.Config)

local Remotes = script.Parent.Parent.Remotes

local DEBUG = false

local NEARBY_BOARD_RADIUS = 50
Expand Down Expand Up @@ -399,16 +401,8 @@ return {

if VRService.VREnabled then

local penToolTemplate = ReplicatedStorage:FindFirstChild("Chalk")
assert(t.instanceOf("Tool", {
Handle = t.instanceOf("MeshPart", {
Attachment = t.instanceOf("Attachment")
})
})(penToolTemplate))

local penTool: Tool = penToolTemplate:Clone()
penTool.CanBeDropped = false
penTool.Parent = Players.LocalPlayer:WaitForChild("Backpack")
Remotes.RequestVRChalk:FireServer()
local penTool = Players.LocalPlayer:WaitForChild("Backpack"):WaitForChild("Chalk")

ControllerMaid._watchPen = watchPen(penTool)

Expand Down
4 changes: 4 additions & 0 deletions lib/Remotes.model.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
{
"Name": "RequestBoardInit",
"ClassName": "RemoteEvent"
},
{
"Name": "RequestVRChalk",
"ClassName": "RemoteEvent"
}
]
}
14 changes: 14 additions & 0 deletions lib/Server/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local Remotes = root.Remotes
local Config = require(root.Config)
local DataStoreService = Config.Persistence.DataStoreService
local BoardServer = require(script.BoardServer)
local t = require(script.Parent.Parent.t)
local Maid = require(script.Parent.Util.Maid)
local Persistence = require(root.Persistence)
local Binder = require(root.Util.Binder)
Expand Down Expand Up @@ -72,6 +73,19 @@ function Server:Start()
end
end)

Remotes.RequestVRChalk.OnServerEvent:Connect(function(player: Player)
local penToolTemplate = ReplicatedStorage:FindFirstChild("Chalk")
assert(t.instanceOf("Tool", {
Handle = t.instanceOf("MeshPart", {
Attachment = t.instanceOf("Attachment")
})
})(penToolTemplate))

local penTool: Tool = penToolTemplate:Clone()
penTool.CanBeDropped = false
penTool.Parent = player:WaitForChild("Backpack")
end)

self.BoardServerBinder:Start()
end

Expand Down

0 comments on commit d242049

Please sign in to comment.