I made this script which goes in a brick. The script should check in startergui if the gui stated in it has the text "-[Completed]." If the text says completed then the brick would be cancollidable.
local debounce = false script.Parent.Touched:connect(function(hit) if debounce == false then wait() debounce = true local player = game.Players:FindFirstChild(hit.Parent) if player and Startergui.Quests[player.Name].Frame6.quest6.Value == "-[Completed]" then script.Parent.CanCollide = false wait(.5) script.Parent.CanCollide = true end --I placed the debounce inside the if statement, so that it only gets reset by the function call that set it wait(2) debounce = false end end)
You're referencing the GUI the player originally gets, rather than the one he currently has. You'll want to reference the PlayerGui rather than StarterGui. The code should look something like this:
local debounce = false script.Parent.Touched:Connect(function(hit) if debounce == false then wait() debounce = true local player = game.Players:FindFirstChild(hit.Parent) if player and player:WaitForChild("PlayerGui").Quests[player.Name].Frame6.quest6.Value == "-[Completed]" then script.Parent.CanCollide = false wait(.5) script.Parent.CanCollide = true end --I placed the debounce inside the if statement, so that it only gets reset by the function call that set it wait(2) debounce = false end end)
This is what I got from your post at least. Reply to this if your situation is different.