I'm making a game, as lots do. I want to make a gate open when you talk to a guard, but you need to have 20 coins. I've tried doing this in my best ability but I cant get anything to work. This is my script: (Also, I'm a beginner to scripting, so if it looks messy than you know why)
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Click:Play()
local Click = script.Parent.MouseButton1Click
script.Parent.Parent.Visible = false
game.Workspace.Guard.Head.ProximityPrompt.ActionText = "Bring Coins"
game.Workspace.Guard.Head.ProximityPrompt.Enabled = true
script.Parent.Parent.Dialogue.Text = "Placeholder"
script.Parent.Parent.Dialogue2.Text = "Where are the coins?"
local player = game.Players:GetPlayerFromCharacter()
if player.leaderstats.Coins.Value == 20 then
game.StarterGui.Dialogue.WesternCitizens.GuardOpenningDialogue.Background.Dialogue2 = "Oh, you have what I need! Go on through.!"
end
end)
game.Workspace.Map.Gates.DesertGate:Destroy()
Is there any help I could get with this?

4 comments
this script is in the guard?
This script is inside of StarterGUI. Im firing it, and since it pops up it works, it just doesn't check the value.
Thats what I need help with
oh ok i just saw these. I gave a responce below, i hope it helps