#Shop script by Proximity prompt

1 messages · Page 1 of 1 (latest)

undone yarrow
#

I need assistance with correcting this script, there are no red lines, and it won't really tell me what i'm doing wrong..

Button = script.Parent:FindFirstChild("ShopButton")
GUI = game.StarterGui:FindFirstChild("Shop")

if Button.PromptButtonHoldBegan then
    Button.PromptButtonHoldBegan:Connect(function()
        GUI.Enabled = true
    end)
end
#

I'd ask someone on my team for help, but they don't know either..

hoary lynx
#

Are you trying to make so when you trigger the proximity prompt a gui gets enabled?

hoary lynx
#

If so, you need to use the triggered function

undone yarrow
hoary lynx
#

Change the Button.PromptButtonHoldBegan to Button.Triggered to see if it works

undone yarrow
#

okay

hoary lynx
#

Also you don't need that if statement

undone yarrow
hoary lynx
undone yarrow
hoary lynx
undone yarrow
hoary lynx
#

yeah because you didn't put an end) at the end to close the function and you're repeating button.Triggered

#

Just delete the button.Triggered top line and put an end) at the end of the script

undone yarrow
hoary lynx
#

Send the script

undone yarrow
#
Button = script.Parent:FindFirstChild("ShopButton")
GUI = game.StarterGui:FindFirstChild("Shop")

Button.triggered
    Button.triggered:Connect(function()
        GUI.Enabled = true
    end)
hoary lynx
undone yarrow
#

Ok, I removed it

hoary lynx
#

It should work now i guess

undone yarrow
#

It doesn't

hoary lynx
#

Any errors in output?

undone yarrow
#

None

#

Oh wait, I think i need to make the script a child of the prompt

hoary lynx
#

Oh

undone yarrow
hoary lynx
#

You placed the script inside of the proximity prompt right?

hoary lynx
#

So you would need to change:

Button = script.Parent

undone yarrow
#

Oh, right..

#

No errors, but won't work

hoary lynx
#

Oh i just noticed

#

You're referencing your gui in a wrong way

undone yarrow
#

OHHHH

hoary lynx
#

Oh no nevermind

#

Forget what i said, this won't work in the server

undone yarrow
#

I am wanting to make this a local script so it only acts for the player

#

unless it does it reguardless?

hoary lynx
#

Oh

#

So you just need to move the local script to starterGui, or starterPlayer or starterCharacter

#

But you will need to do:

Button = game.Workspace.ShopButton

#

Or reference wherever the proximity prompt is inside of the workspace

hoary lynx
scarlet solstice
#

I think I know ur problem, ur using starter gui instead of the actual players gui

arctic sand
#

Triggered must be capital

scarlet solstice
past wind
#

then button.triggered:connect

#

remove button.triggered

#

and triggered needs to be spelt Triggered

#

Lua is case sensitive

undone yarrow
past wind
#

Also

#

It needs to be game.players.localplayer.playergui

#

With case ofcourse

#

Because startergui is replicated to the client, you have to adjust the clients gui.

#

The startergui does nothing when replicated

undone yarrow
#

Oh

undone yarrow
#

Will ":FindFirstChild("Shop")"

past wind
#

Yeah, add that after

undone yarrow
#

work?

past wind
#

Sure

undone yarrow
#
Button = script.Parent
GUI = game.players.localplayer.playergui:FindFirstChild("Shop")

    Button.Triggered:Connect(function()
        GUI.Enabled = true
    end)
past wind
#

Game.Players.LocalPlayed.PlayerGui

cedar sageBOT
#

studio** You are now Level 22! **studio

past wind
#

Try that

#

Does it work?

undone yarrow
past wind
#

LocalPlayer

#

My bad

#

Typo

undone yarrow
past wind
#

Wait a minute

undone yarrow
#

Uh, okay

past wind
#

Try :WaitForChild("PlayerGui")

undone yarrow
#

oh, because it might not be there yet

#

?

past wind
#

Probably

undone yarrow
#

Same error

#
Button = script.Parent
GUI = game.Players.LocalPlayer.PlayerGui:WaitForChild("Shop")

    Button.Triggered:Connect(function()
        GUI.Enabled = true
    end)
past wind
#

No I meant

#

Player: WaitForChild

#

LocalPlayer:WaitForChild

#

Then PlayerGui

undone yarrow
# past wind Then PlayerGui
Button = script.Parent
GUI = game.Players.LocalPlayer.LocalPlayer:WaitForChild.("PlayerGui")

    Button.Triggered:Connect(function()
        GUI.Enabled = true
    end)
past wind
#

Remove the first localplayer

#

And the dot after waitforchild

undone yarrow
#

Oh, derp

past wind
#

Then add .Shoo

#

Shop

#

Or your gui name

undone yarrow
#
Button = script.Parent
GUI = game.Players.LocalPlayer:WaitForChild("PlayerGui").Shop

    Button.Triggered:Connect(function()
        GUI.Enabled = true
    end)
past wind
#

Yes it should work now

arctic sand
#

Big dog you need to do your captials better

undone yarrow
past wind
#

Ohh

#

Why is the script inside a script?

#

It should be a local script

undone yarrow
#

Oh

past wind
#

Inside of playerscripts

cedar sageBOT
#

studio** You are now Level 7! **studio

undone yarrow
#

Hold on

past wind
#

By the way this is your choice, but I feel like you would need to learn a bit more about studio before trying to make a game no?

#

Local scripts are for each client, default scripts are for the game/server

undone yarrow
past wind
#

Oof, that must be.. stressful?

undone yarrow
#

I know a bit of Javascript, that's all i know about coding

past wind
#

I'm sure learning Lua or Luau won't be a problem then

undone yarrow
#
Button = workspace.Lobby.Shop.ShopBlock.ShopButton
GUI = game.Players.LocalPlayer:WaitForChild("PlayerGui").Shop

Button.Triggered:Connect(function()
    GUI.Enabled = true
end)
past wind
#

Is the script inside of starterplayerscripts?

undone yarrow
#

Yes

past wind
#

Try WaitForChild

#

This problem happens alot

#

Use WaitForChild and insert shopblock

#

workspace.Lobby.Shop:WaitForChild("ShopBlock").ShopButton

undone yarrow
#

IT WORKS

#

Thank yall so much for helping me

past wind
#

No problem!

#

I love helping people in sxriptinghelp because it's these small issues that make big differences lol

#

At least now you know the difference between local and default scripts

#

Also if you are planning to learn Roblox studio, make sure you practice module scripts! Everyone uses them and they are very practical.

undone yarrow
#

Well, I'm a builder, that's my main job

past wind
#

Oh, well that's unexpected lol

#

A bit weird telling a builder to script.. lol?

#

Well when you have no other options I guess you have to find suitable ones

undone yarrow
#

Who else are they gonna ask? A consept artist? though, it would be funny watching them get confused

past wind
#

Haha, anyways good luck with your game!