Still have questions? Join our Discord server and get real time help.
Log in to vote

How to check for a local part on the server?

Asked by 8 months ago

I'm making a script that needs to see if a local part exists or not. please help!

sent a comment on your question raid6n 2309 — 8mo

2 answers

Log in to vote
Answered by 8 months ago

If the "local part" is created by the client, it will simply not exist on the server due to properties of Filtering Enabled.

The part will only exist on the client. If you want to check if a part exist on both the client and the server you can use a RemoteEvent to send the part object and check if it's nil or not.

RemoteEvent.OnServerEvent:Connect(function(player, part)
    if (part) then
        print(part.Name .. " exists on server.")
        print("Part doesn't exist on server.")

RemoteEvent:FireServer("Part", workspace))


Baseplate exists on server.

Part doesn't exist on server.

Good luck.

Log in to vote
Answered by
raid6n 2309 Moderation Voter Community Moderator
8 months ago
Edited 8 months ago

for _, Model in pairs(workspace:GetChildren()) do     if Model.Name = "ButtonModel" then code else code end end
what is ButtonModel? ffancyaxax12 181 — 8mo
A Part that you are looking for. raid6n 2309 — 8mo
Put ButtonModel as the part ur looking for raid6n 2309 — 8mo
I substituted "ButtonModel" for "RedPart". And when I create the instance "RedPart" with a local script I did not get a read out. i also changed code with print("Yes")) ffancyaxax12 181 — 8mo
View all comments (4 more)
It didn’t work? raid6n 2309 — 8mo
No, or im not understanding the script ffancyaxax12 181 — 8mo
It didn't work because you're using a LocalScript to insert a part into the workspace. So it's Client Sided, not Server Sided. To insert a part, use a Server Script for the server to pass it through it's connections and verify it's existence into the game. In summary, use ServerScripts for things you want everyone to see or have an affect with, and use a LocalScript in GUI's for only the person... killerbrenden 1435 — 8mo
and other stuff for only the person to see who's using the computer. YouTube is a great way to learn scripting. killerbrenden 1435 — 8mo

Answer this question