So Basically I want to clone something where the mouse was clicked here is the code.
local replicated_Storage = game:GetService("ReplicatedStorage") local event = replicated_Storage.Event local UserInputService = game:GetService("UserInputService") local player = game:GetService("Players").LocalPlayer local mouse = player:GetMouse() mouse.Button1Down:Connect(function() event:FireServer() end)
Second piece of code: Server side
local replicated_Storage = game:GetService("ReplicatedStorage") local event = replicated_Storage.Event local UserInputService = game:GetService("UserInputService") local black_Hole = replicated_Storage:WaitForChild("BlackHole") event.OnServerEvent:Connect(function(player) local mouse = player:GetMouse() local new_Blackhole = black_Hole:Clone() new_Blackhole.Parent = game.Workspace new_Blackhole.Position = Vector3.new(mouse.X,mouse.Y,0) new_Blackhole.Anchored = true print(new_Blackhole.Position) end)
Hello!
The property X and property Y of mouse are not replicated to the server.
Additionally, the X and Y position of the mouse describes the mouse's position on the screen, not the physical location within the Workspace.
But this is why Mouse.Hit exists!
Mouse.Hit will give you a CFrame value of the mouse's physical location within the world!
To convert the CFrame in to a Vector3 value like you're trying to use, you can do CFrame.Postion.
Also note that the Mouse.Hit property is client replicated, so you should send the information through the remote event!
I'll try to fix your scripts below:
Local Script:
local replicated_Storage = game:GetService("ReplicatedStorage") local event = replicated_Storage.Event local UserInputService = game:GetService("UserInputService") --You didn't use the UserInputService. Any reason its here? local player = game:GetService("Players").LocalPlayer local mouse = player:GetMouse() mouse.Button1Down:Connect(function() event:FireServer(mouse.Hit) end)
Server Side:
local replicated_Storage = game:GetService("ReplicatedStorage") local event = replicated_Storage.Event local UserInputService = game:GetService("UserInputService") local black_Hole = replicated_Storage:WaitForChild("BlackHole") event.OnServerEvent:Connect(function(player, Hit) local new_Blackhole = black_Hole:Clone() new_Blackhole.Parent = game.Workspace new_Blackhole.Position = Hit.Position new_Blackhole.Anchored = true print(new_Blackhole.Position) end)