Gui with Frame not opening after ingame coin is collected. Works fine otherwise

  1. What do you want to achieve?

I would like a shop UI to appear when activating a proximity prompt.

  1. What is the issue?

For some reason, collecting a coin that increases a leaderstat value stops me from opening the shop. At all other times, you can open and close the shop Ui freely.
YT Link on the video: roblox problem - YouTube

  1. What solutions have you tried so far?

I have tried replacing the script opening the shop with a local script, and instead of cloning the Shop Gui, it would make the frame visible from the StarterGui. This did not open the Frame at all.

Shop Opening Script:

-- Shop opening script: 

   script.Parent.ProximityPrompt.Triggered:Connect(function(Player)

	local ShopGui = game.ServerStorage.ShopGui:Clone()
	
	ShopGui.Parent = Player.PlayerGui
	
	ShopGui.Enabled = true
	
	ShopGui.ScrollingFrame.Visible = true

end)

Coin Collecting Script:

--Coin collecting script: 

local Players = game:GetService("Players")
local Debounce = 1

local Coin = script.Parent

YPos = 0
XPos = Coin.Orientation.X
ZPos = Coin.Orientation.Z

Coin.Touched:Connect(function(HitPart)

	if HitPart.Parent:FindFirstChild("Humanoid") then

		if Debounce == 1 then

			Debounce = 0

			local Player = Players:GetPlayerFromCharacter(HitPart.Parent)

			HitPart.Parent:FindFirstChild("HumanoidRootPart").Position = Vector3.new(-129.5, -13.9, 0.75)

			Player.leaderstats.Points.Value += 3

			Coin.Transparency = 1

			task.wait(3)

			Coin.Transparency = 0

			Debounce = 1

		end


	end

end)

while true do

	Coin.Orientation = Vector3.new(XPos,YPos,ZPos)

	YPos += 2

	task.wait()


end

Thank you for your help! This problem truly confuses me, and I have absolutely no idea how to fix it.

2 Likes

There’s nothing immediate that catches my eye other than the fact that you are cloning the gui over to the player instead of just having it in startergui, but otherwise it should work. Could you post the part of the script that closes your shop? The problem is most likely there and you have probably attributed it wrongly to collecting the coin.

1 Like

Within the Scrolling frame, there is a textbutton that when pressed, deletes the clone. Here is the code.


script.Parent.MouseButton1Click:Connect(function()

	script.Parent.Parent.Parent:Destroy()

end)

And here is what it looks like from the explorer:
image

Keep in mind that without first collecting the coin, I can open and close the shop whenever I want.

Edit: Ok, so, I’ve noticed something. For SOME reason, the HumanoidRootPart affects this bug.


local Players = game:GetService("Players")
local Debounce = 1

local Coin = script.Parent

YPos = 0
XPos = Coin.Orientation.X
ZPos = Coin.Orientation.Z

Coin.Touched:Connect(function(HitPart)

	if HitPart.Parent:FindFirstChild("Humanoid") then

		if Debounce == 1 then

			Debounce = 0

			local Player = Players:GetPlayerFromCharacter(HitPart.Parent)

			HitPart.Parent:FindFirstChild("HumanoidRootPart").Position = Vector3.new(-129.5, -13.9, 0.75)

			Player.leaderstats.Points.Value += 3

			Coin.Transparency = 1

			task.wait(3)

			Coin.Transparency = 0

			Debounce = 1

		end


	end

end)

while true do

	Coin.Orientation = Vector3.new(XPos,YPos,ZPos)

	YPos += 2

	task.wait()


end

Do you notice the “HitPart.Parent:FindFirstChild(“HumanoidRootPart”).Position = Vector3.new(-129.5, -13.9, 0.75)”? When I temporarily removed this part of the script, the shop would continue working as normal. My theory is that somehow, this is what is breaking the Gui.

1 Like

I didn’t even notice this.
It’s good practice if you want to teleport a player to modify their CFrame instead, it causes some humanoid physics to break sometimes if you use position.
This shouldn’t have any affect on the gui at all, but maybe there’s a desync for your position on the client and the server and thats why the proximity prompt isn’t firing??
Either way; I’d try replacing that line with this.

HitPart.Parent:FindFirstChild(“HumanoidRootPart”).CFrame = CFrame.new(Vector3.new(-129.5, -13.9, 0.75))
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.