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

Why doesn't this BoolValue-based Script work?

Asked by 7 years ago

Alright, so I've tried a lot of things, like basing the debounce off of a brick's color, which failed, and eventually, I came to BoolValues. I set up my script like this:

01local enabled = true
02script.Parent.Touched:Connect(function(het)
03    if het.Parent.Name == "Can" and enabled then
04        local char = het.Parent.Parent
05        local PlayerWhoClicked = game.Players:GetPlayerFromCharacter(char)
06 PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Font = "SourceSans"
07    PlayerWhoClicked.PlayerGui.TalkGui.Frame.Visible = true
08    PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Text = "You watered the Flower."
09    wait(3)
10    PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Text = "Go tell ParentFigure!"
11    wait(1)
12    PlayerWhoClicked.PlayerGui.TalkGui.Frame.Visible = false
13    game.Workspace.Flower.Watered == true -- Watered is the bool.
14    end
15end)

the receiving side of the script would be this:

01function onClicked(PlayerWhoClicked)
02    PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Font = "SourceSans"
03    PlayerWhoClicked.PlayerGui.TalkGui.Frame.Visible = true
04    local name = PlayerWhoClicked.Name
05if workspace.Flower.Watered == true then
06    PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Text = "You watered the plant?"
07    wait(2)
08    PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Text = " "
09    PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Text = "Oh, aren't you the greatest!"
10    wait(3)
11    PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Text = "Well, I guess you should be going."
12    wait(3)
13    PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Text = "Bye! Don't forget to visit from time to time..."
14wait(3)
15    PlayerWhoClicked.PlayerGui.TalkGui.Frame.Visible = false
View all 21 lines...

and when I go through the steps to get to the final dialogue, this error happens.

18:17:54.647 - Watered is not a valid member of Model

I've tried and tried, but it won't work. Any ideas why?

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

It seems you are trying to check the value of a BoolValue, in this case you need to do

1game.Workspace.Flower.Watered.Value == true

add '.Value' to access the actual value of the boolean

also, if you are trying to change the value of the bool, only use one '='

Ad

Answer this question