How can I fix this? I have a script that once a player steps on a Part, it opens a GUI but, it only opens once. I have a localscript that fires an event which adds coins to the players inventory, but, the GUI only appears once, how do I change that so whenever they step on the part and the collected value is false, it opens how do I do this?
local guiname = "RewardGUI"
script.Parent.Touched:connect(function(hit)
if hit == nil then return end
if hit.Parent == nil then return end
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player ~= nil and player.collected.Value == false then
if player:FindFirstChild("PlayerGui") then
if not player.PlayerGui:FindFirstChild(guiname) then
local ui = script.Parent:FindFirstChild(guiname):clone()
ui.Parent = player.PlayerGui
end
end
end
end)

3 comments
Okay, final question. So this is for a daily reward, when the player leaves and joins back they can go over and the GUI will appear again, how do I fix this?
store its name and check if the name was stored or not if it wasn't then make the gui appear if it was then it won't appear
I think I understand what you are trying to say, but unfortunately I can't say I understand this fully.