Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to check for a local part on the server?

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

1 comment

0

sent a comment on your question

2 answers

✓ Accepted answer

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.


for _, Model in pairs(workspace:GetChildren()) do
    if Model.Name = "ButtonModel" then

    code
     else
       code
end
end

8 comments

0

what is ButtonModel?

0

A Part that you are looking for.

0

Put ButtonModel as the part ur looking for

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"))

0

It didn’t work?

0

No, or im not understanding the script

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...

0

and other stuff for only the person to see who's using the computer. YouTube is a great way to learn scripting.

This discussion is preserved as it was. New answers, comments, and votes are closed.