How do I transfer something to workspace from Rep Storage?

Hello, I’m new to developing and I’ve so far come across two problems…

One : How do I enable/Disable the GUI once an Intermission timer has reached a certain time left?

Two : How do I move a map from Replicated Storage to Workspace once the intermission timer has reached a certain time left?

For Q-1 I tried making this:

seconds = game.Workspace.Time

if seconds == 5 then
game.StarterGui.SET1.Enabled = true
else
game.StarterGui.SET1.Enabled = false
end

But it didn’t Work ._.

Please Help me!

Thank you!
-DragonBossJ1212

3 Likes

There isn’t much information that you have provided, however, if I am correct, the “time” object in workspace is a value. The code should be:

seconds = game.Workspace.Time

if seconds.Value == 5 then
game.StarterGui.SET1.Enabled = true
else
game.StarterGui.SET1.Enabled = false
end
3 Likes

Should this be in a Script or Local script? Currently it’s a Local script in the GUI file itself and yes, game.workspace.time is a Value in Workspace. :slight_smile:

Making a change to StarterGui won’t affect anyone. That container is used to hold Guis that are replicated to players when they start: its static. You should actually be aiming to change the copy in PlayerGui, which you can handle from a LocalScript itself and detect when to hide the Gui.

1 Like

I’m really sorry but i’m still Confused! :frowning: As I said, I am very new to this Scripting stuff! :frowning:

This should be in a local script. To simplify what ScriptingSupport said, you should manipulate the GUI, from the PlayerGui, locally. When playing the game, changes in the StarterGuis will not affect the player.

1 Like

Oh, Ok, Thank you guys! :slight_smile: :slight_smile:

Indeed, the changes will not affect until the user respawns (I believe, correct me if I’m wrong.) Although there are some ways to change the Guis of a player. The best and efficient way to do this is by doing it trough events. If you need help working with events feel free to send me a DM on Discord. ScrxedDev#5848

At the moment your script is only checking the timer value once and not every time the timer value changes. This is the reason why it isn’t working as intended and the way to fix this is by using the changed event. The other issue that your code has is that it isn’t referencing the GUI correctly. Instead of doing game.StarterGui.SET1, all you need to do is change it to game.Players.LocalPlayer.PlayerGui.SET1. This method goes to the player service, goes through the LocalPlayer and then goes to the PlayerGui.

Your other issue that you said you are having is that you want to move a map from ReplicatedStorage to workspace. This should be done on the sever because this will allow the map to be visible to every other player instead of just a specific client. The way you do this is by using the Clone event as shown in this article on the developers hub: https://developer.roblox.com/en-us/api-reference/function/Instance/Clone


You may now be thinking how do I add this to my code. If I am correct all you want to do is load a map once a timer has gone down and then display a GUI. Here is a little tutorial on how to do this:

First you will need to create a script and place it in ServerScriptService. Once you have done that you will need to place this code within it:

local ReplicatedStorage = game:GetService("ReplicatedStorage") -- Creates a reference for ReplicatedStorage
local seconds = workspace.Time -- Creates a reference for the timer value

seconds.Changed:Connect(function() -- Fires whenever the time value in workspace changes
	if seconds.Value == 5 then
		local Clone = ReplicatedStorage.Map:Clone() -- Clones the map from replicated storage
		Clone.Parent = workspace -- Places the cloned map in workspace
	end
end)

Next we will need to create a LocalScript and place it on the client. It would be better to place it within the GUI we are going to be working with, in this case SET1, as it will help keep everything tidy.

local ReplicatedStorage = game:GetService("ReplicatedStorage") -- Creates a reference for ReplicatedStorage
local seconds = workspace.Time -- Creates a reference for the timer value

seconds.Changed:Connect(function() -- Fires whenever the timer value changes
	if seconds.Value == 5 then 
		game.Players.LocalPlayer.PlayerGui.SET1.Enabled = true -- Makes the GUI enabled
	end
end)
4 Likes

Thank you so much! Really Helpful!! :smiley:

1 Like