How did it break in which way? Was it like a duplication issue or just a lag issue?
Is the :PrepareRenderPreview the :PreparePreviewModel func?
There would be no preview but it you left-click it places down, either way :PreparePreviewModel() is the problem.
When it checks to see if there’s a preview, it says nil when there is clearly one.
@haydengamingdo Yes it is, my bad.
In the :ChangePreview func, try adding an if statement to see if the self.SelectedObject is found in the Objects folder before running the :PreparePreviewModel
The problem is not in any of these functions! The problem is the following:
You have two scripts, one called client (in playerscripts) and one in the gui. The “client” script creates a ClientPlacer object and changes it blah blah BUT the script in the gui cannot access that object, because it was created in a different script (“client”)
You have to convert your two scripts into one that acts as a wrapper for the actual object.
SO:
Merge “client” (Starterplayerscripts) and “LocalScript” (GUI)
Thank you, ill try this out,
And i’ll try this one out aswell.
EDIT: This one does not work since it loads in the correct model.
It won’t be as easy as copying the lines, you have to change quite alot because you made a fatal mistake when building the whole system.
You should change the Placer class so that it does not need to be deleted when the b button is pressed, instead the placer should just hide the preview by deleting the model.
Okay, i’ve moved the code into the clientPlacer function.
Now i’m getting this problem:
Argument 1 missing or nil -
Here’s the line of code from where this happens:
self.SelectedObject = objects:WaitForChild(objectName)
Here’s the new function (called at ClientPlacer.new)
function ClientPlacer:ButtonPressed(player: Player)
local ui = player.PlayerGui.ItemGui
local scrollFrame = ui.SelectFrame.SelectList
for _, button in pairs(scrollFrame:GetChildren()) do
if button:IsA("Frame") then
button.ItemName.MouseButton1Click:Connect(function()
local objectName = button.ItemName:GetAttribute("ItemName")
self:ChangeObject(objectName)
end)
end
end
end
Isn’t your ItemName attribute inside of the ItemFrame according to your first post on this topic?
Oops, i Screwed up. Thanks for telling me, i might need a break lol
Edit: Same error still.
Haha! Nice pun, I really needed a joke or some way to cheer me up because I’m so bored.
Also, is the ItemName instance a button or a textlabel
Where you are calling the :ChangePreview, you didn’t add a “player” instance before the object name as your ChangePreview func requires a Player and a Name
I understand that what I’m about to say might be controversial, and perhaps even better left unsaid, but here’s my honest perspective:
I believe it would be beneficial for you to dive deeper into the principles of Object-Oriented Programming (OOP) and explore how others have approached projects similar to yours (on youtube for example).
At this stage, it seems like you might not be fully prepared to tackle this challenge effectively. While I don’t feel comfortable writing the script for you or providing a step-by-step solution, I’d encourage you to take a step back and carefully analyze the problem. Problem-solving is a core skill for any programmer, and it’s essential to approach issues methodically.
Right now, it seems like you’ve implemented what I’d describe as a “duct-tape fix.” It might work for now, but it’s not a sustainable or robust solution. Taking the time to build a solid foundation will ultimately help you create something more reliable and efficient.
FINALLY, IT WORKS… IT WORKS
Thank you all,everyone for the support! We have finally fixed the bug, now who do i give the solution to?
You’re welcome, I’d say to give it to who helped the most on fixing the issue, but as the other person said, you might want to learn how to problem solve for scripting.