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

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!

0
sent a comment on your question raid6n 2309 — 8mo

2 answers

Log in to vote
0
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.

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

--client
RemoteEvent:FireServer(workspace.Baseplate)
RemoteEvent:FireServer(Instance.new("Part", workspace))

Output:

Baseplate exists on server.

Part doesn't exist on server.

Good luck.

Ad
Log in to vote
3
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
0
what is ButtonModel? ffancyaxax12 181 — 8mo
0
A Part that you are looking for. raid6n 2309 — 8mo
0
Put ButtonModel as the part ur looking for raid6n 2309 — 8mo
0
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)
0
It didn’t work? raid6n 2309 — 8mo
0
No, or im not understanding the script ffancyaxax12 181 — 8mo
0
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
0
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