✓ Accepted answer
You are trying to set the surface of part INSIDE the client script
Please note that the client world doesn't replicate to other client world but only the server world will replicate the change to the client world. Unless you're trying to remove the outline of part surface ONLY in the client but the following code will utilize RemoteEvent.
RemoteEvent is a special part that serves as a communication tool for clients and servers. It's like how software communicates with hardware by using kernel code but much simpler. Functions are different for a different type of script (LocalScript and ServerScript): See Roblox article for more (https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events)
I also add a check if the part is actually part and not others (stringValue, script, etc.) because you want all parts in the workspace to be set.
==== CODE ====
LocalScript
local btn1 = script.Parent.TextButton
local btn2 = script.Parent.TextButton2
local remote = game.ReplicatedStorage.RemoteEvent
btn1.MouseButton1Click:Connect(function()
Remote:FireServer()
end)
ServerScript
local remote = game.ReplicatedStorage.RemoteEvent
remote.OnServerEvent:Connect(function()
for i, v in pairs(workspace:GetChildren()) do
if workspace:FindFirstChild("Camera") or workspace:FindFirstChild("Terrain") then
return
end
if v:IsA("Model") then
for j, w in pairs(v:GetChildren()) do
if w:IsA("Part") then
w.TopSurface = Enum.SurfaceType.Smooth
w.BottomSurface = Enum.SurfaceType.Smooth
end
end
end
if v:IsA("Part") then
v.TopSurface = Enum.SurfaceType.Smooth
v.BottomSurface = Enum.SurfaceType.Smooth
end
end
end)
NOTE: Allowing anyone to remove the outline from every part of the workspace is extremely dangerous and a user ID check is recommended but the code shown above is not including a user ID check.
If you're trying to remove the outline ONLY from the user perspective then this answer will not be helpful. But if you did want to remove the outline in every player's perspective then in the future, you probably want to research about RemoteEvent and RemoteFunction because these things are important for the game.
Happy Scripting!
4 comments
Also, I did put the "wasd" there to my title so my issue can get accepted because I can't explain the title more.
Didn't thought about that, great strategy
Wait so you want to make the TopSurface and BottomSurface to Smooth, and thats its?
for every part in workspace, yes.