✓ Accepted answer
Your script is working exactly as it should. It's updating the Gui in StarterGui. This means that you won't see the change until your character reloads, as the contents of StarterGui are cloned into each player's PlayerGui folder on CharacterAdded. To fix this, all you need to do is get the Gui from the PlayerGui folder using a RemoteEvent, because the server cannot do this.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = Instance.new("RemoteEvent")
Remote.Parent = ReplicatedStorage
script.Parent.ClickDetector.MouseClick:Connect(function(player)
Remote:FireClient(player,"")
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild("RemoteEvent")
local player = game:GetService("Players").LocalPlayer
Remote.OnClientEvent:Connect(function(args)
if player.PlayerGui:FindFirstChild("PurchaseGui") then
player.PlayerGui.PurchaseGui.PurchaseFrame.Visible = true
end
end)
Note that Local Scripts will only run when they are or were at some point a direct descendant of the player. This includes places like StarterPack, StarterGui, and StarterPlayerScripts.
##Resources:
Local Script
##Accept and upvote if this helps!
4 comments
You're modifying the StarterGui instead of the actual gui the player has. Just use a localscript for the onclicked event, and check if the person who clicked it was the localplayer. If it was, then enable the gui.
MouseClick is not responsive to Local Scripts. it must be used on the server
no, not true, local scripts can listen for the MouseClick event
ok roblox changed that bc the wiki used to explicitly say otherwise. gg