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

Script dosent work even though it did the first time?

heres the script containing a script to pull up a gui:

Local ShopBlock = script.Parent

ShopBlock.Touched:connect(function(Hit) local H = HIT.Parent:FindFirstChild("Humanoid") if H then local Player = game.Players:GetPlayerFromCharacter(HIT.Parent) Player.PlayerGUI.ShopGUI.Frame.Visible = true end end)

its called ShopBlock for most of the parts because that is what the part is called wih this script is in

3 answers

✓ Accepted answer

if your game is filtering enabled along with what low strife said you need to use a bindable event like this i make a folder of events then name all of them for this ill use guiOpener as the name this is the script in the block

Local ShopBlock = script.Parent

ShopBlock.Touched:connect(function(Hit) 
local H = Hit.Parent:FindFirstChild("Humanoid")
 if H then
 local Player = game.Players:GetPlayerFromCharacter(Hit.Parent) 
game.ReplicatedStorage.Events.guiOpener:Fire(player, "ShopGui")

 end
 end)

make another script in the serverScriptService then name it (I like to put it in a folder but thats your choice )

then add this code:

game.ReplicatedStorage.Events.guiOpener..Event:Connect(function(Player, gui)
if gui = "ShopGui" then
Player.PlayerGUI.ShopGUI.Frame.Visible = true
end
end)

2 comments

0

it worked!~ imaginevreything with the Every spelt wrong

0

you can use this for opening other guis too

Lua is case sensitive. You said HIT.Parent:FindFirstChild("Humanoid") but it you defined it as Hit inside the function. Also, change connect to Connect, because the former is deprecated.

1 comment

0

connect vs Connect doesn't really matter much.

Well I would make a script like this:

debounce = false

local function onTouch (hit)
if hit.Parent:findFirstChild("Humanoid") then -- checks if its the player!
if not debounce then -- prevents a ton of hits
debounce = true
local char = hit.Parent
local player = game.Players:GetPlayerFromCharacter(char)

local gui = player.PlayerGui:WaitForChild("ShopGUI")

gui.Frame.Visible = true

end
end
debounce = false
end

script.Parent.Touched:Connect(onTouch)

Well this should work! Put it in your part! Use a normal script!

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