Why doesn't this BoolValue-based Script work?
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:
02 | script.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." |
10 | PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Text = "Go tell ParentFigure!" |
12 | PlayerWhoClicked.PlayerGui.TalkGui.Frame.Visible = false |
13 | game.Workspace.Flower.Watered = = true |
the receiving side of the script would be this:
01 | function onClicked(PlayerWhoClicked) |
02 | PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Font = "SourceSans" |
03 | PlayerWhoClicked.PlayerGui.TalkGui.Frame.Visible = true |
04 | local name = PlayerWhoClicked.Name |
05 | if workspace.Flower.Watered = = true then |
06 | PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Text = "You watered the plant?" |
08 | PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Text = " " |
09 | PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Text = "Oh, aren't you the greatest!" |
11 | PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Text = "Well, I guess you should be going." |
13 | PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Text = "Bye! Don't forget to visit from time to time..." |
15 | PlayerWhoClicked.PlayerGui.TalkGui.Frame.Visible = false |
18 | PlayerWhoClicked.PlayerGui.TalkGui.Frame.TextLabel.Text = "Water the plant, " .. name |
20 | PlayerWhoClicked.PlayerGui.TalkGui.Frame.Visible = false |
21 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |
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?