I’m trying to call a function after my variable, “Game1” changes from 0 to 1.
local trigger = game.Workspace.Hall.trigger
local Tel1 = workspace.Stage1.Stage1Brick
local tsound = -- roblox sound id
local Game1 = 0
local function triggered()
print("Triggered")
tsound:Play()
wait(10)
tsound:Stop()
end
local function FGame1()
if Game1 == 1 then
print("oh yeah")
end
end
trigger.Touched:Connect(function(poop)
if poop.Parent:FindFirstChild("Humanoid") then
Game1 = 1
local Character = poop.Parent
Character:SetPrimaryPartCFrame(Tel1.CFrame)
trigger.Parent = nil
triggered()
end
end)
Game1.Changed:Connect(FGame1())
I’m getting an error message saying:
Players.gubuyguy3.PlayerScripts.trigger:35: attempt to index number with ‘Changed’
It’s the wrong way to go about things though. It’d be better to have a function dedicated to setting the value of the variable, and also calling any functions that need to be called when it does change.