Here is a script for a shop part that activates a gui when stepped on and deactivates when a remote event is fired or it’s stepped off of. (credit to @4467hp)
local Players = game:GetService("Players")
local Part = script.Parent
Part.Touched:Connect(function(Hit)
local Player = Players:GetPlayerFromCharacter(Hit.Parent)
if not Player then return end
if not Player.PlayerGui:FindFirstChild("GUIClonedfromtouchblock") then
local Clonedgui = script.Parent:FindFirstChildOfClass("ScreenGui"):Clone()
Clonedgui.Name = "GUIClonedfromtouchblock"
Clonedgui.Parent = Player.PlayerGui
end
end)
Part.TouchEnded:Connect(function(Hit)
local Player = Players:GetPlayerFromCharacter(Hit.Parent)
if not Player then return end
local Ui = Player.PlayerGui:FindFirstChild("GUIClonedfromtouchblock")
Ui:Destroy()
end)
local storage = game:GetService("ReplicatedStorage")
local event = storage.exit
event.OnServerEvent:Connect(function(player)
local ui = player.PlayerGui:FindFirstChild("GUIClonedfromtouchblock")
ui:Destroy()
end)
The script works as expected, but I get the error anyway. In my experience, this usually completely stops the script from working so it’s a bit odd. Is it something I should be worried about?