Remove Textures for No Lag Gone Wrong

Hello Developers!

So I’m a ro-football developer, and my fanbase was asking if I could add a “smoothfield” chat command to remove textures just for that player.

Well, the command works, but it does it for everyone in the server. I’m not the best programmer, so how can I just make this for the player?

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		if message == "smoothfield" then
			for i, v in pairs(workspace:GetDescendants()) do
				if v:IsA("BasePart") then
					v.Material = Enum.Material.SmoothPlastic
				end
			end
			
		end
	end)
end)

Hello, this can easily fixed by converting this script to a Client script. I have done this here for you, all you need to do is insert this code into a LocalScript either in StarterGui or StarterPlayerScripts and you should be good to go. Let me know if there are any questions.

local player = game.Players.LocalPlayer

player.Chatted:Connect(function(message)
	if message == "smoothfield" then
		for i, v in pairs(workspace:GetDescendants()) do
			if v:IsA("BasePart") then
				v.Material = Enum.Material.SmoothPlastic
			end
		end
			
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.