Hello, So I have been working on my upcoming game and I have run into a problem with the track PlacementScript.
In the track it has 2 main parts the “ConnectorPart” and the “JointPart”
Whats meant to happen is that when you place a track it will move the building part to the new track joint part and so on but for some reason it will only let me place one track.
I have tried many ways to fix this but I just can’t seem to.
Here is my script.
local TrackPlacementEvent = game.ReplicatedStorage:WaitForChild("TrackPlacementEvent")
local TrackFolder = game.ReplicatedStorage:WaitForChild("Tracks")
local BuildingPoint = game.Workspace:WaitForChild("SpawnTrack").JointPart
local NewBuildingPoint = false
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local TrackFrames = script.Parent.Parent.PlacementTracksFrame
local PlacingObject = false
local CanPlaceTrack = true
for i, TrackButtons in pairs(TrackFrames:GetChildren()) do
if TrackButtons:IsA("Frame") then
TrackButtons.BuildTrackButton.MouseButton1Click:Connect(function()
print(TrackButtons.Name)
if not PlacingObject then
if CanPlaceTrack == true then
local PreviewTrack = TrackFolder:FindFirstChild(TrackButtons.Name):Clone()
PreviewTrack.Parent = workspace
local newBuildingPoint = PreviewTrack.JointPart
if NewBuildingPoint == false then
PreviewTrack:SetPrimaryPartCFrame(BuildingPoint.CFrame)
else
PreviewTrack:SetPrimaryPartCFrame(newBuildingPoint.CFrame)
end
NewBuildingPoint = true
print(NewBuildingPoint)
end
end
end)
end
end
If you would like anymore information or screenshots feel free to ask
Thank you