So I want to make a placeable tool. This is the script I made:
local Tool = script.Parent
FC = script.Parent:WaitForChild("ClientToServer")
use = true
function script.Parent.ClientToServer.OnServerInvoke(player, mouse_pos)
if use then
use = false
local StickyBomb = Tool.Handle:Clone()
StickyBomb.Parent = workspace.DebriCleaner
StickyBomb.Name = "StickyBomb"
StickyBomb.CanCollide = true
StickyBomb.Anchored = true
StickyBomb.Size = Tool.Handle.Size
StickyBomb.CFrame = Vector3.new(mouse_pos)
use = true
end
end
But It doesn’t work. I the clone of the tool handle to go anchored on the position where the mouse position is. But it doesn’t work: the only error I get is:
Note your setting a CFrame which is a positional, and position object. You can view the documentation here. CFrame | Roblox Creator Documentation You can pass a Vector3 in to set its position, but you have to use CFrame.new
Nevermind. I noticed that if I place it on the baseplate that it doesnt place where i clicked. it places in the middle of the baseplate. how do i fix it?
plr = game.Players.LocalPlayer
mouse = plr:GetMouse()
tool = script.Parent
tool.Activated:Connect(function()
local FC = tool:WaitForChild("ClientToServer")
if FC then
FC:InvokeServer(mouse.Hit)
end
end)
I see… change your server code from StickyBomb.CFrame = CFrame.new(Vector3.new(mouse_pos))
to
StickyBomb.CFrame = mouse_pos
Mouse | Roblox Creator Documentation The documentation for Mouse.Hit shows that it returns a CFrame, since you’re passing this to the server, you can just pass the CFrame value directly to the part you’re trying to update.