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

Accessing the property of an object using a string value?

Let's say that there is a remoteevent instance "changevalue"

And you fire it, you have the parameter; Instance, Property of instance, Value.

Let's say that you want to change the transparency of the part to 1. Ignore any errors that may exist in the script below, this is just an example.

part = game.Workspace.Part

Script.Parent.changevalue:FireServer(part, "Transparency",1)

So in a serverscript elsewhere, it would change the property of that part to the new value/

In a server script what would the function look like? Assuming that you are trying to make this as general as possible.

1 answer

local RemoteEvent = game.ReplicatedStorage.RemoteEvent

RemoteEvent.OnServerEvent:Connect(function(Player, Instance, Property, Value)
	if typeof(Instance) ~=" Instance" then
		return
	end

	if type(Property) ~= "string" then
		return
	end

	pcall(function()
		Instance[Property] = Value
	end)
end)

You should never have a remote like this in your game under any circumstances. Any exploiter can chang ethe property of any instance that is visisble to them. You would never want to do something like this. Instead, consider alternative solutions to your problem.

Remember, exploiters can intercept and fire any remote at any time with any arguments, and the only argument you can trust from the client is the Player argument, which is passed implicitly and validated by the player's authorization token.

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