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

Variable within a Variable Help? [closed]

Asked by 9 years ago

So I need some help with setting a variable to a different variable. Here's the code block:

I am trying to get the value of Shipsname (Which is the models name that is in Workspace) and put it into another variable called Object. This models name varies and so I need a variable to represent it.(Called Shipsname)

Shipsname = game.Players.LocalPlayer.Character.Shipsname--Working on this
Camera = game.Workspace.CurrentCamera
Object = game.Workspace.Shipsname.BodyKit.Grok
Player = script.Parent.Humanoid
Camera.CameraSubject = Object
Camera.CameraType=3
while true do
wait()
    if Player.Sit == false then
    Camera.CameraSubject = Player
    script:Remove()
    end
end

Help is appreciated. Sorry if its confusing. I'll try and clear up any questions you may have.

Locked by EzraNehemiah_TF2, Redbullusa, and BlueTaslem

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 9 years ago
Shipsname = game.Players.LocalPlayer.Character.Shipsname--Working on this and Change the name of Shipsname to ShipsName
Camera = game.Workspace.CurrentCamera
Object = game.Workspace[Shipsname.Name].BodyKit.Grok
Player = script.Parent.Humanoid
Camera.CameraSubject = Object
Camera.CameraType=3
while wait() do
    if not Player.Sit then
    Camera.CameraSubject = Player
    script:Remove()
    end
end

Edited again.

0
You changed the while loop but that doesn't have much to do with the variable issue. lordrex12345 25 — 9y
0
I didn't only change that. EzraNehemiah_TF2 3552 — 9y
0
I'll try and re-explain. The model name is going to change. Therefore I need a variable that changes with it. In this case I want that variable to be "Shipsname". The problem is, the program thinks that when I say game.Workspace.Shipsname, it things the model is called "Shipsname" when its actually something that the variable represents. lordrex12345 25 — 9y
0
Done, I edited. EzraNehemiah_TF2 3552 — 9y
View all comments (5 more)
0
I got this error: 16:31:08.162 - Workspace.Player.CameraChange:17: bad argument #2 to '?' (string expected, got userdata) 16:31:08.164 - Script 'Workspace.Player.CameraChange', Line 17 16:31:08.165 - Stack End lordrex12345 25 — 9y
0
Sorry, That was an object value not a string. I found my mistake. EzraNehemiah_TF2 3552 — 9y
0
Ok it didn't work the first time so I just changed the Shipsname.Name to Shipsname.Value. After that, things worked smoothly so thanks alot! lordrex12345 25 — 9y
0
You never said that Shipsname was a value. EzraNehemiah_TF2 3552 — 9y
0
Ah, well it was. heh lordrex12345 25 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Why in the world do you want a variable within a variable...?

0
I've tried to explain it in the previous answer's comments. lordrex12345 25 — 9y