Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can someone help me with me fix the positions my blocks spawn?

So basically 3rd question I solved the other two by the way. So now I have gotten the position of the mouse and the x and y But since I just want the block to spawn in the direction of the mouse spawning from the torso how do I do this? when I test it. It says it expects vector3 but I only have 2 coordinates and as such I want to use Vector2 Heres the script: (Sorry I dont know how to use the code blocks :sad_face:) local Players = game:GetService("Players")

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local createPartEvent = ReplicatedStorage:FindFirstChild("Spells")

local cooldown = "on"

local mouse = ReplicatedStorage:FindFirstChild("Mouse")

local function Recieved(player, mouse)

if cooldown ~= "off" then

local torso = player.Character:WaitForChild("HumanoidRootPart")

local Part = Instance.new("Part")

Part.Parent = torso

Part.CFrame= torso.CFrame + Vector2.new(mouse) ---This is from the remote event and has the code mouse.X and mouse.Y

cooldown = "off"

wait(10)

cooldown = "on"

wait(10)

Part:Destroy()

end

end

mouse.OnServerEvent:Connect(Recieved)

1 answer

I am a bit confused from your vague question, and do not know the client side, however! I am still going to attempt to give you a solution to this.

Mouse.Hit a built in function to the Mouse that will return a CFrame, and instead of using Vector2.new() you can now get the exact position easily with .Hit, as it will grant a Z axis given it is not directly associating the position with the mouse, rather getting the Mouse and where it hit, and the CFrame of that position.

Here's an example

local Player = game.Players.LocalPlayer

local Mouse = Player:GetMouse()

  

Mouse.Button1Down:Connect(function()

print(Mouse.Hit)

end)

Put that into the output and you will get a CFrame! And not a Vector2 or X or Y axis of the mouse, a simple CFrame.

Now, replace that code with whatever is Firing to the server, and then replace the Vector2 with the argument name, which is already a CFrame to begin with.

This discussion is preserved as it was. New answers, comments, and votes are closed.