Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why not open shop gui when touch part?

Asked by 6 years ago
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

0
why are you waiting for the playergui DaCrazyDev 444 — 6y
0
why are you waiting for the playergui DaCrazyDev 444 — 6y
0
until he finds. I do not know. a few weeks I started to learn lua sebo90PL 0 — 6y
0
Look on yt and it'll help you. madlyholland -53 — 6y
0
I've already looked for nothing sebo90PL 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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

0
This is a very simple version of course you can improve it, of course MageMasterHD 261 — 6y
0
However, this script can only show the shop but not close it anymore MageMasterHD 261 — 6y
0
thx sebo90PL 0 — 6y
0
you could just use the not operator as a toggle, instead of using booleans User#23365 30 — 6y
View all comments (4 more)
0
and :connect() deprecated, use :Connect() User#23365 30 — 6y
0
what where? sebo90PL 0 — 6y
0
I already fixed it just copy and paste the script again :) MageMasterHD 261 — 6y
0
still the same sebo90PL 0 — 6y
Ad

Answer this question