I'm trying to produce a code where once a block in the workspace is touched the following happens...

A value is added to the serverstorage counter A player gui button is made visible

I know the serverstorage value adder works but the button won't become visible. I know I'm making a fundamental error but is still can figure out what it is. The script is located in the workspace as a child of the block that is touched and the code is as follows. Any help would be greatly appreciated.

game.Workspace.TreehouseWarp.Touched:Connect(function(hit)
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player ~= nil then
			if hit.Parent:FindFirstChild("Humanoid") then
				local Gui = game.Players:FindFirstChild(player.Name)
				if Gui ~= nil then 
					Gui.PlayerGui.TeleportGui.Menu.TreeHouse.Visible = true
				end
					
				local Stats = game.ServerStorage.TreehouseUnlock:FindFirstChild(player.Name)
				if Stats ~= nil then 
					Stats.Value = Stats.Value + 1
					wait(2)
				end					
				
			end
		end
end)

3 comments

0

Why is the server editing GUI? The client should do that.

0

I am storing the cumulative value in serverstorage. Essentially I originally wrote the script using game.players.localplayer but it would unlock the gui and increase the counter for all players on the server and i could figure out why

0

function ZDUnlock() script.Parent.Parent.PlayerGui.TeleportGui.Menu.ZoraDomain.Visible = true script.Parent.Parent.PlayerGui.TeleportGui.Menu.ZoraDomain.Selectable = true game.Players.LocalPlayer.transporterunlocks.ZoraDomainUnlock.Value = game.Players.LocalPlayer.transporterunlocks.ZoraDomainUnlock.Value + 1 wait(0.1) end game.Workspace.ZoraWarp.Touched:Connect(ZDUnlock)