hello,
so for my game, players have to spawn cubes.
and it was going really well until i placed one on the wall.
it spawned half inside the wall and i don’t know how to fix it…
how do i do that?
Localscript:
local Folder = script.Parent
local Tool = Folder.Parent
local Event = Folder:WaitForChild("Task")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local BlockName = Tool.Name.."Block"
local Ghosts = game.ReplicatedStorage.GhostBlocks
local RealGhost = Ghosts:FindFirstChild(BlockName)
local RunService = game:GetService("RunService")
local Clone = nil
local Connection = nil
Tool.Activated:Connect(function()
Event:FireServer(BlockName,Mouse.Hit.Position)
end)
Tool.Equipped:Connect(function()
Clone = RealGhost:Clone()
Clone.Parent = workspace
Connection = RunService.Heartbeat:Connect(function(t)
Clone.Position = Mouse.Hit.Position + Vector3.new(0,2,0)
end)
end)
Tool.Unequipped:Connect(function()
Clone:Destroy()
Connection:Disconnect()
end)
script:
local Folder = script.Parent
local Event = Folder:WaitForChild("Task")
local Tool = Folder.Parent
Event.OnServerEvent:Connect(function(plr,Name,Position)
local Cube = game.ServerStorage.Blocks:FindFirstChild(Name):Clone()
Cube.Parent = workspace
Cube.Position = Position + Vector3.new(0,2,0)
Tool:Destroy()
end)
Thanks in advance!