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

Accessing the property of an object using a string value?

Asked by 6 years ago

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

Log in to vote
0
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago
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.

Ad

Answer this question