Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why not open shop gui when touch part?

debounce = false

function onTouched(hit)
    local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
    if plr and debounce == false then
        debounce = true
        
        plr:WaitForChild("PlayerGui").ShopGui.Frame.Visible = true
        debounce = false
    end
end

script.Parent.Touched:connect(onTouched)

how touch part open shop did not work

5 comments

0

why are you waiting for the playergui

0

why are you waiting for the playergui

0

until he finds. I do not know. a few weeks I started to learn lua

0

Look on yt and it'll help you.

0

I've already looked for nothing

1 answer

The script does not work because there is no shop gui in the PlayerGui for the server this can only be used via local script (or with a remote function)

local RemoteEvent = Instance.new("RemoteEvent")
RemoteEvent.Parent = game.Workspace
RemoteEvent.Name = "ShopEvent"

function onTouched(hit)
    local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
    RemoteEvent:FireClient(plr)
end

script.Parent.Touched:Connect(onTouched)

this script is placed in the brick

game.Workspace:WaitForChild("ShopEvent")
local debounce = false

game.Workspace.ShopEvent.OnClientEvent:Connect(function ()
	if debounce == false then
		script.Parent.Frame.Visible = true
		debounce = true
	end
end)

this script is placed in a local script in the shop gui

8 comments

0

This is a very simple version of course you can improve it, of course

0

However, this script can only show the shop but not close it anymore

0

thx

0

you could just use the not operator as a toggle, instead of using booleans

0

and :connect() deprecated, use :Connect()

0

what where?

0

I already fixed it just copy and paste the script again :)

0

still the same

This discussion is preserved as it was. New answers, comments, and votes are closed.