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

How to check for a local part on the server?

Asked by 4 years 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 2196 — 4y

2 answers

Log in to vote
0
Answered by 4 years 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 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

for _, Model in pairs(workspace:GetChildren()) do     if Model.Name = "ButtonModel" then code else code end end
0
what is ButtonModel? ffancyaxax12 181 — 4y
0
A Part that you are looking for. raid6n 2196 — 4y
0
Put ButtonModel as the part ur looking for raid6n 2196 — 4y
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 — 4y
View all comments (4 more)
0
It didn’t work? raid6n 2196 — 4y
0
No, or im not understanding the script ffancyaxax12 181 — 4y
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 1537 — 4y
0
and other stuff for only the person to see who's using the computer. YouTube is a great way to learn scripting. killerbrenden 1537 — 4y

Answer this question