Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
BashGuy10 384 Moderation Voter
5 years ago

(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

01local place = game:GetService("ReplicatedStorage").Placement.Remotes.Place
02 
03 
04game.ReplicatedStorage.Placement.Remotes.Place.OnServerEvent:Connect(function(plr, building, position)
05 
06 
07    local building2 = building:Clone()
08    building:MoveTo(position)
09    building.Parent = workspace
10 
11 
12end)

LOCAL SCRIPT

01local player = game:GetService("Players").LocalPlayer -- Define the player
02local mouse = player:GetMouse() -- Define the mouse
03local UIS = game:GetService("UserInputService") -- UIS for activate of placement
04local active = true -- Is placement active?
05local activekeycode = Enum.KeyCode.E -- When the player presses E, they start placement.
06local event = game:GetService("ReplicatedStorage").Placement.Remotes.Place
07local changeevent = game:GetService("ReplicatedStorage").Placement.Remotes.ChangeBuilding
08local currentbuilding = game:GetService("ReplicatedStorage").Placement.Buildings.Model
09 
10 
11 
12--UIS.InputBegan:Connect(function(input, gp) Not in use
13    --if input == activekeycode and gp and active then
14        --active = true
15    --else
View all 37 lines...
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 greatneil80 2647 — 5y
0
I'll probably end up using Tweens when i get it somewhat setup. BashGuy10 384 — 5y
0
Oh also, use :GetTouchingParts for collisions and raycasting for when the model goes outside the boundaries! greatneil80 2647 — 5y
0
Gonna have to use that to. BashGuy10 384 — 5y
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. SteamG00B 1633 — 5y

1 answer

Log in to vote
1
Answered by
Dfzoz 489 Moderation Voter
5 years ago

The problem is on the server script:

01local place = game:GetService("ReplicatedStorage").Placement.Remotes.Place
02 
03 
04game.ReplicatedStorage.Placement.Remotes.Place.OnServerEvent:Connect(function(plr, building, position)
05 
06 
07    local building2 = building:Clone()--Cloned the original building
08    building:MoveTo(position)--Original building was referenced instead of the clone, you moved the original building
09    building.Parent = workspace--Same problem here, you moved the building to the workspace
10    --Just change the building to building2 on lines 8 and 9 and you should be good to go
11 
12end)
0
It doesn't work, it won't move but it clones! Problem two out of the way Screenshot: https://gyazo.com/9f17a26479fb598f940eeae951a8a41a BashGuy10 384 — 5y
0
Maybe changing the order of the code. Change the building2 Parent first and then then move it and try it out Dfzoz 489 — 5y
0
It worked, don't know why it needs to be parented first. Thanks  BashGuy10 384 — 5y
Ad

Answer this question