Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My model placement system is not working, it clones the model but doesn't move?(read desc)

(I had to shorten the title because of the stupid 100 char limit)

Hello! I'm having some troubles with my model placement, it clones the model but doesn't move it until you click again. AND doesn't clone another part. Help would be appreciated

FYI: I'm using remote events

GIF of the placement system

Replicated storage(Ignore "changebuilding")

SERVER SCRIPT

local place = game:GetService("ReplicatedStorage").Placement.Remotes.Place


game.ReplicatedStorage.Placement.Remotes.Place.OnServerEvent:Connect(function(plr, building, position)
	
	
	local building2 = building:Clone()
	building:MoveTo(position)
	building.Parent = workspace
	
	
end)

LOCAL SCRIPT

local player = game:GetService("Players").LocalPlayer -- Define the player
local mouse = player:GetMouse() -- Define the mouse
local UIS = game:GetService("UserInputService") -- UIS for activate of placement
local active = true -- Is placement active?
local activekeycode = Enum.KeyCode.E -- When the player presses E, they start placement.
local event = game:GetService("ReplicatedStorage").Placement.Remotes.Place
local changeevent = game:GetService("ReplicatedStorage").Placement.Remotes.ChangeBuilding
local currentbuilding = game:GetService("ReplicatedStorage").Placement.Buildings.Model



--UIS.InputBegan:Connect(function(input, gp) Not in use
	--if input == activekeycode and gp and active then
		--active = true
	--else
		--active = false
	--end
--end)
	
	
mouse.Button1Down:Connect(function()--Start the placement
	--if active then -- Ensure it is active
		print("Activated")
		
		local building = currentbuilding
		local position = mouse.Hit.p -- Don't know if i should use "mouse.Hit.p" or "mouse.Hit"
		event:FireServer(building, position)
	--end
end)


-- IGNORE THIS!!!!!!!!!!!!!!!!!
changeevent.OnClientEvent:Connect(function(building)-- Change building
	if not active and building ~= currentbuilding then -- Ensure it is not active
		currentbuilding = building
	end
end)

5 comments

0

I made my placement system neater by using TweenService:Create() and cancelled the tween every time the mouse moved..!! Also I used mouse.Hit.p

0

I'll probably end up using Tweens when i get it somewhat setup.

0

Oh also, use :GetTouchingParts for collisions and raycasting for when the model goes outside the boundaries!

0

Gonna have to use that to.

0

Just going to say this: if you plan to do something in the future that changes your whole system because you think it will make it cleaner, it is better to do it sooner rather than later or else your future self will hate you.

1 answer

✓ Accepted answer

The problem is on the server script:

local place = game:GetService("ReplicatedStorage").Placement.Remotes.Place


game.ReplicatedStorage.Placement.Remotes.Place.OnServerEvent:Connect(function(plr, building, position)


    local building2 = building:Clone()--Cloned the original building
    building:MoveTo(position)--Original building was referenced instead of the clone, you moved the original building
    building.Parent = workspace--Same problem here, you moved the building to the workspace
	--Just change the building to building2 on lines 8 and 9 and you should be good to go

end)

3 comments

0

It doesn't work, it won't move but it clones! Problem two out of the way Screenshot: https://gyazo.com/9f17a26479fb598f940eeae951a8a41a

0

Maybe changing the order of the code. Change the building2 Parent first and then then move it and try it out

0

It worked, don't know why it needs to be parented first. Thanks 

This discussion is preserved as it was. New answers, comments, and votes are closed.