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

How do i change a value of a bool value with a bool value?

Asked by 6 years ago
Edited 6 years ago

This line of code is not working for me. And i don't really know why. What i'm trying to do is to change a bool value with another bool value and i'm finding the bool value with a string value. I checked that i have done right and finding the values so i don't think that's an error. However it gives me this error:

"attempt to index a nil value"

game.Workspace.Values.Voting.Result.Survive.Value=game.Lighting:FindFirstChild(game.Workspace.Values.Voting.Result.Value):FindFirstChild("survival").Value


EDIT:

I solved this! In another script i swithced the parent of the model to workspace, to make it work i need to search the model in the workspace and not in the lighting. game.Workspace.Values.Voting.Result.Survive.Value=game.Workspace:FindFirstChild(game.Workspace.Values.Voting.Result.Value):FindFirstChild("survival").Value


I solved this now!

2 answers

Log in to vote
0
Answered by 6 years ago

What is the other bool value location? And the name..

0
The bool value i want my bool value to change to is located in: game.Lighting.(Model) and is named: "survival". In lighting i have three diffrent models and the result string value is chossing one of thosse names of the models. bondhemlig 20 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
local a =game.Lighting:FindFirstChild(game.Workspace.Values.Voting.Result.Value)
local b = a:FindFirstChild("survival").Value

game.Workspace.Values.Voting.Result.Survive.Value = b

Tell me if this gives you the wrong outcome, or errors.

0
No, but it gave me the error for the variable a. bondhemlig 20 — 6y

Answer this question