I’m running this code simply to check if “SprintSpeed” is a valid property of humanoid and instead of just returning false and continuing it is erroring on the if statement?
if character.Humanoid[stat] then
character.Humanoid[stat] = NewValue
end
You can use this function to check if a property is on a provided instance, but like @SomeFedoraGuy said: you cannot assign custom properties to instances.
local function isValidProperty(instance: Instance, name: string): boolean
local success = pcall(function() -- wrap this in an error catcher to not break the thread
return instance[name] -- index the property to see if it errors
end)
return success -- this will return true if the property was attached to the instance, or false if it errored/not attached to the instance
end