Why Does this Script only work in roblox studio

The Gui does not Show Up When The ProximityPrompt Is Triggered
it only popup with the UI In Studio

local Trig = game.Workspace:WaitForChild(“Quest1Box”).ProximityPrompt
local Value = game.Workspace:WaitForChild(“Quest1”).Chests

Trig.Triggered:Connect(function()

script.Parent.Parent.Enabled = true

if Value.Value == 3 then 
	script.Parent.Parent.Gradient.TextLabel.Text = "Thank You So Much! For Returning My Treasures"
	wait(3)
	script.Parent.Parent.Gradient.TextLabel.Text = "I Have A Reward For You Take This DogeCoin!"
	wait(0.2)
	game.Players.LocalPlayer.leaderstats.DogeCoin.Value = game.Players.LocalPlayer.leaderstats.DogeCoin.Value + 6000
	wait(1)
	game.Workspace.Quest1.Parent = game.ReplicatedStorage
else
	script.Parent.Gradient.TextLabel.Text = "No You Dont You Liar 😡"
	script.Parent.NoButton.Visible = false
    script.Parent.YesButton.TextLabel.Text = "Im Sorry 😭"
end

end)

3 Likes

untested guess …

local Trig = game.Workspace:WaitForChild("Quest1Box").ProximityPrompt
local Value = game.Workspace:WaitForChild("Quest1").Chests
local GUI = script.Parent.Parent

Trig.Triggered:Connect(function()
	GUI.Enabled = true

	if Value.Value == 3 then 
		GUI.Gradient.TextLabel.Text = "Thank You So Much! For Returning My Treasures"
		wait(3)
		GUI.Gradient.TextLabel.Text = "I Have A Reward For You Take This DogeCoin!"
		wait(0.2)
		game.Players.LocalPlayer.leaderstats.DogeCoin.Value = game.Players.LocalPlayer.leaderstats.DogeCoin.Value + 6000
		wait(1)
		game.Workspace.Quest1.Parent = game.ReplicatedStorage
	else
		GUI.Gradient.TextLabel.Text = "No You Dont You Liar 😡"
		GUI.NoButton.Visible = false
		GUI.YesButton.TextLabel.Text = "Im Sorry 😭"
	end
end)

1 Like

didnt work did the same as the first script

1 Like

What do you mean only in studio?

1 Like

so it dosent work in real games only roblox studio

1 Like

have you checked in console for any errors?

1 Like

no errors i checked both game and studio

1 Like

Is it a LocalScript or a Script?
Where is the script located in the Explorer window?

For troubleshooting purposes before an if statement, print the variable being checked to see if it’s what’s incorrect for the situation you expect.

print("Value.Value = ",Value.Value)
if Value.Value == 3 then 
--code
2 Likes

it is a local script in ScreenGui

1 Like

The Problem is the gui is not showing up

1 Like

Is everything in the screengui set to visible?

1 Like

But my question is specific.
Where is the GUI, and its parents, and its children? It’d really help if you posted a screenshot of its location including the Workspace at the top, the items in the workspace that lead down to the GUI as well as the script.
It lets us know if the location of the GUI and script are the cause of the problem.

In Studio testing alll the scripting is handled by your computer.
In game all of the local stuff is handled by your computer. All the Server sided stuff (scripts) are handled by the Server computer.

I understood from your first post that the problem is the GUI isn’t showing up. I’m trying to get information that tells us the details about what may cause the issue.

2 Likes

yes why would it work in studio but not the game

1 Like

here

2 Likes

the script is the selected in the explorer

1 Like

wait i found an error let me try fix it

i fixed it Yay thank guys for the help

1 Like

One thing that stuck out to me was this line … Not sure it has anything to do with you’re problem.

game.Workspace.Quest1.Parent = game.ReplicatedStorage

This seems very odd. You move a copy (clone) of the chest to the workspace, then delete it when done. I’ve never saw a case where you move anything back to ReplicatedStorage or to it from the workspace. Not even sure a local script can do that …

I just tried a simple reformat without really testing or looking at it that deeply till now.

Please let everyone know what your fix was so people having the same issue can find out how you solved it. :grinning:

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