How do i make Variables?

(I’m using version 1.19.3)

I’m making a game thingy and I need to make variables but I have no idea how to.

I’ve tried typing in
float.example = 0 , Float.example = 0 , and example = 0
but none work

any help?

Welcome to the forums.

First off, Wick uses java script as its language.

You can declare a variable only useable in the scope it is declared in with

let myVariable = 400;

You can have any value whether its a number like 15, a string like "Hello world", an array like [30,18,47,42], a object like {myString:"green",myNumber:5,myArray:[1,5,2,6]} or a function.

From what I know if you declare a let variable in a script tab in can only be accessed from the script tab. If its declared in something like a if or for statement it can only be accessed inside that statement.

Another way you can declare a variable is with something like

var myVariable = "Hello world";

It works fairly similar to let but I think if its declared in a if or for statement it can used outside although I’m not 100% sure about that.

Const declares a variable that can’t be changed.

const multiplier = 4.5;

In the example above it will always be 4.5 during runtime because it can’t be changed.

I don’t know if you can access it from other script tabs though.

In Wick you can also declare variables with this. in a clip which make it able to be accessed in other script tabs and clips.

this.health = 20;

If you are accessing it from the same clip in a different script tab you can use this.health (or whatever you named the variable).
If you are accessing from a different clip that replace this with the name of that clip.

You can also declare a global variable with window.

window.myNum = 100;

Then to access it you can use window.myNum (myNum or whatever the variable name is) or if there is no variable named myNum then you could access it with just myNum

Here is a page about js variables https://www.w3schools.com/js/js_variables.asp

1 Like

thank you!

you can also for instance just do project.health = "value" or player_health = "value" etc.