Hi, I have a problem where I get the error as stated in the title when I am getting the position using player:GetMouse(), then using HumanoidRootPart.Position - mouse.Hit.Position.
here is the code:
local mouse = player:GetMouse()
userInput.InputBegan:Connect(function(input, gpe)
if input.KeyCode == Enum.KeyCode.R and gpe == false then
if tool.Parent == player.Backpack or character then
if debounce == true then
remoteEvent:FireServer(mouse.Hit.Position)
end
end
end
end)
server script:
remoteEvent.OnServerEvent:Connect(function(player, mouseP)
if (humanoidRootPart.Position - mouseP).magnitude <= 50 then
distance.Value = .2
end
end)
But the weird part is that it happens randomly it feels like.
game:GetService("RunService").RenderStepped:Connect(function()
if debounce2 == true then
wait(.15)
game.ReplicatedStorage.RemoteEvents.WaterRemotes.ChangeMouse:FireServer(mouse.Hit.p)
end
end)
local mouseP
remoteEvent2.OnServerEvent:Connect(function(player2, mousePosition)
mouseP = mousePosition
end)
oh thats totally different from the script above
I am not sure I would fire it like this maybe even just use a mousechanged on userinput for when it changes position
Renderstepped is not something you should probably fire constantly to the server most cases you want to use it for something visual on the client side that needs updated
ok so maybe you should only send over mouse update as the parts are being added to the workspace. from what i see the mouse pos is being used to aim the parts projection?
it could. what I would do which you maybe is I create and render all on the client just send the type of attack and then positions they need to render to to the server then it fires and gives that info to all clients to render
yeah on first update. sometimes heartbeat can be used also but you are firing so many times to the server with that render it will probably cause some lag or timeouts even if over firing the event
lol seems some things get deprecated that are very useful and some have it listed when they are not
yeah its cool I learn everyday mainly from trial and error and there maybe even a better way to do it than what I am suggesting I have tested a few ways and find that you client render and just send server values to update other clients really with projectiles. and depending on your hit use raycasting detections
many things you can create and have only client side physics and nothing but a value server side