I am trying to create a part that transfers all the properties of the old part into the server and deleting the old one for a placement system.
When I press the button, it simply just creates a ton of parts that do absolutely nothing.
Localscript (in a button in startergui)
local button = script.Parent
local PlaceEvent = game.ReplicatedStorage:WaitForChild("Events").PlaceEvent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local RS = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
button.MouseButton1Down:Connect(function()
local part = game.ReplicatedStorage.Towers.Part:Clone()
part.Parent = workspace
placeRSF = RS.RenderStepped:Connect(function()
part.Position = mouse.Hit.p
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
PlaceEvent:FireServer(part.CFrame.p)
part:Destroy()
placeRSF:Disconnect()
end
end)
end)
end)
ServerScript (in serverscriptservice)
local RS = game:GetService("ReplicatedStorage")
local events = RS:WaitForChild("Events")
local placeEvent = events.PlaceEvent
placeEvent.OnServerEvent:Connect(function(plr, towerCFrame)
local mouse = plr:GetMouse()
local tower = game.ReplicatedStorage.Towers.Part:Clone()
tower.Parent = workspace
tower.Anchored = true
tower.Position = towerCFrame
end)
No error message.