I have tried almost everything i can to fix it but im not gettig no error message so i dont know what to do i was wondering if one of you can help me solve this issue here is the code:
local frame = game.StarterGui.ShopGui.AURA_SHOP_NAME
local frame2 = game.StarterGui.ShopGui.MAIN_FRAME
local part = game.Workspace["Aura shop"].Shop.ShopPart
part.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
frame.Visible = true
frame2.Visible = true
end
end)
part.TouchEnded:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
frame.Visible = false
frame2.Visible = false
end
end)
Assuming this is a Script, you have three issues.
To fix these issues, add a RemoteEvent to ReplicatedStorage, and try this :
-- find the remote event
local remoteEvent = game.ReplicatedStorage.RemoteEvent
-- keep a dictionary to count how many parts are touching the shop
local counts = {} -- [player name] : counter
-- find the shop part
local part = game.Workspace["Aura shop"].Shop.ShopPart
part.Touched:Connect(function(hit)
-- when a player touches the shop, add one to the counter
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if not counts[player.Name] then
counts[player.Name] = 0
-- a player has just started touching the shop, show the screen
remoteEvent:FireClient(player, true)
end
counts[player.Name] += 1
end
end)
part.TouchEnded:Connect(function(hit)
-- when the player stops touching, subtract one from the counter
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
counts[player.Name] -= 1
if counts[player.Name] == 0 then
-- all the parts have stopped touching the shop, hide it
remoteEvent:FireClient(player, false)
counts[player.Name] = nil
end
end
end)
Then put a LocalScript in the StarterGui, it will listen for when the server tells the client to show the shop.
-- find the UI elements
local shopGui = script.Parent.ShopGui
local frame = shopGui.AURA_SHOP_NAME
local frame2 = shopGui.MAIN_FRAME
-- find the remote event
local remoteEvent = game.ReplicatedStorage.RemoteEvent
-- listen for messages from the server
remoteEvent.OnClientEvent:Connect(function(isVisible)
frame1.Visible = isVisible
frame2.Visible = isVisible
end)