How Do I Change Properties With Script?

Hello Developers! :hammer_and_wrench:

I’m wondering how I can change the properties of a different object (The object you’re not scripting) using script. Thank you in advance for your help!

Happy Building!
~ Blox

3 Likes

Which property are you talking about exactly?

The value of “WalkAnimationID”.

I’m sort of trying to extend off of the Roblox Build It Play It Challenge.

So WalkAnimationID is the object.

EDIT: I want to change the value at certain points.

Could you send a picture of it in your Explorer? With the object itself and its properties?

Sure! It’ll take about 10 minutes to take it. (I need to get my device with Roblox Studio installed)

1 Like

Okay, here it is:

Annotation 2020-08-11 125854

I haven’t tested this, but it might work

local ServerStorage = game:GetService("ServerStorage")

ServerStorage.Animations.WalkAnimationID.(Property you want to change) = (What you want it changed to)
2 Likes

So what you want to do, is put a script into ServerScriptService, and write this code:

local walkanim = game.ServerStorage.Animations.WalkAnimationID

walkanim.Value = 01234567 -- replace this with your id
1 Like

Isn’t it called WalkAnimationID? What is walkanim?

Okay, thank you! I’ll mark this as solution if it works!

1 Like

It’s the variable for the WalkAnimationID.

2 Likes

The reason it was walkanim is because he shortened it. You don’t have to say the full path every time if you declare it earlier. For example, say I had a intValue deep in the workspace, for example…

workspace.Model.Part.intValue

I could shorten the time it takes to reach it by doing this:

local value = workspace.Model.Part.intValue
2 Likes

@Bloxy_0001 It is easy just do this(you dont need a variable)

game.ServerStorage.Animations.WalkAnimationID.Value = 12345678 – replace this with your id

1 Like

@creepersaur @Inconcludable @DecodedMint || How would you do that if you wanted the value to be blank? I want it to switch from my id to blank.

If you want it to be nothing, you can state it as nil. Just make sure declaring it as nil doesn’t cause any errors!

You could also just do:

WalkAnimationID = “” – to make it have no value ( see that it is a string but nothing happens )

setting as 0 also will do nothing but may end up causing an error…

1 Like
game.ServerStorage.Animations.WalkAnimationID.Value = nil

Like this?

2 Likes

Okay, thank you for your help!

1 Like

Yes, that should work. Stating it as 0 might also work, but nil is just nothing, while 0 is… well 0!

EDIT:
For anyone coming back to this post, I was wrong. Setting the value as nil does work, but it’s better practice to use 0 (since setting it to nil sets it to 0)

2 Likes