You can write your topic however you want, but you need to answer these questions:
im trying to make a placeable tool…
-
What do you want to achieve? Keep it simple and clear!
I want to anchor my tool handle as soon as i click to place it on the ground -
What is the issue? Include screenshots / videos if possible!
when I click to place the tool it refuses to anchor the part, and the tool slides on the floor if im moving.
3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried to make sure that the code was getting run with print functions. it seems to ignore the line of code that anchors the handle, but still prints.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
I’m trying to make a tool that you can place anywhere as long as it is close enough to your character. I used a remote event with a server script to actually place the thing, and a localscript inside the tool for everything else. (finding the mouse position, displaying a preview, etc.)
This is the local script inside the tool,
local player = game:GetService("Players").LocalPlayer
local tool = script.Parent
local replicatedStorage = game:GetService("ReplicatedStorage")
local runService = game:GetService("RunService")
local rootPartPosition
local mousePos
tool.Unequipped:Connect(function() --to unanchor if the tool is dropped
tool.Handle.Anchored = false
end)
tool.Equipped:Connect(function()
tool.Handle.Anchored = false
print("unanchored")
end)
tool.Activated:Connect(function()
rootPartPosition = player.Character.HumanoidRootPart.CFrame.Position
mousePos = game.Players.LocalPlayer:GetMouse().Hit.Position
if math.abs(mousePos.X - rootPartPosition.X) <= 10 and math.abs(mousePos.Y - rootPartPosition.Y) <= 10 and math.abs(mousePos.Z - rootPartPosition.Z) <= 10 then
lookPart.Transparency = 1
replicatedStorage.Place:FireServer(mousePos, tool)
else return end
end)
and the server sided script that places the tool;
local Place = game:GetService("ReplicatedStorage").Place
Place.OnServerEvent:Connect(function(plr, mousepos, tool)
tool.Parent = workspace
tool.Handle.Anchored = true
print("anchored")
tool.Handle.CFrame = CFrame.new(mousepos)
end)
any help is appreciated.
Edit; i ended up figuring out that the handle is being placed and anchored correctly on server-side, but not for the client. this doesn’t solve the issue but i thought it would be helpful to know