so from these 2 scripts when a player clicks the part does not spawn where i want it to it just spawns in the center of the baseplate aka 0,0,0 localscript:
play = game.Players.LocalPlayer char = play.Character mouse = play:GetMouse() cloth = game.ReplicatedStorage.Cloth:Clone() spot = mouse.Hit.p mouse.Button1Down:Connect(function() game.ReplicatedStorage.ClothEvent:FireServer(spot) end)
script:
cloth = game.ReplicatedStorage.Cloth:Clone() game.ReplicatedStorage.ClothEvent.OnServerEvent:Connect(function(player,spot) cloth.Parent = workspace cloth.Anchored = true cloth.Position = spot end)
also on the localscript i would like the part to follow the mouse until the player clicks then place the actual part on the server, i have tried it before but failed it only shows where the player would click
Alright there's a few issues in this. For example you are creating the position of the mouse at the start of the script. this should be created when you activate it. Also you clone the Cloth at the start of the script making this only work once. Here's fixed code for you.
Local Script
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Tool = script.Parent local Player = game.Players.LocalPlayer local Character = Player.Character local Mouse = Player:GetMouse() local Cloth = ReplicatedStorage:FindFirstChild("Cloth") local Activated = false Tool.Activated:Connect(function() local PositionClicked = Mouse.hit.p print(Mouse.Target) if Mouse.Target.Name == "Cloth" then -- This is a bad way of doing it but I just made something temporary. else local posX, posY, posZ = PositionClicked.X, PositionClicked.Y, PositionClicked.Z game.ReplicatedStorage.ClothEvent:FireServer(posX, posY, posZ) end end)
Server Script
local ReplicatedStorage = game:GetService("ReplicatedStorage") local cloth = ReplicatedStorage:FindFirstChild("Cloth") ReplicatedStorage.ClothEvent.OnServerEvent:Connect(function(Player, posX, posY, posZ) local ClothClone = cloth:Clone() ClothClone.Parent = workspace ClothClone.Position = Vector3.new(posX, posY, posZ) end)