Transferring mouse.Hit.p to the server?
Hi, so I'm having some trouble transferring mouse.Hit.p from the client to the server. I'm trying to make a script that spawns a part where I click, but when I run it I get some weird errors. The part doesn't spawn where I click, but rather at a seemingly random point farther away. Also when I print mouse.Hit.p, it gives me the correct point the first time, but every other time I click it just prints the same point. What's up with this?
Client:
01 | local player = game.Players.LocalPlayer |
02 | local mouse = player:GetMouse() |
03 | local RS = game:GetService( "ReplicatedStorage" ) |
04 | local NewPartEvent = RS:WaitForChild( "NewPartEvent" ) |
06 | local mousePosition = mouse.Hit.p |
10 | mouse.Button 1 Down:connect( function () |
12 | if debounce = = false then |
16 | NewPartEvent:FireServer(mousePosition) |
Server:
01 | local RS = game:GetService( "ReplicatedStorage" ) |
02 | local NewPartEvent = RS:WaitForChild( "NewPartEvent" ) |
06 | NewPartEvent.OnServerEvent:connect( function (plr, mousePosition) |
07 | local partTwo = Instance.new( "Part" , workspace) |
08 | partTwo.Position = mousePosition |