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

Script about TweenPosition works in Studio but not in game?

Hello, I've made this simple script that moves GUIs when you touch some parts, in studio, it works fine. But if you go play it on Roblox itself, it doesn't do anything. I have no idea what I've done wrong.. can someone please help me?

Script:

local SG = game:GetService("StarterGui")
local Cs = SG.CutScenes

 
script.Parent.Touched:Connect(function()
	
Cs.UpperFrame:TweenPosition(UDim2.new(0,0,0,-35), "Out", 1) 
Cs.LowerFrame:TweenPosition(UDim2.new(0, 0,0.793, 0),  "Out", 1)
wait(6.25)
Cs.TransPArencyFrame:TweenPosition(UDim2.new(0,0,0,0), "Out", 1)
wait(1.6)
Cs.TransPArencyFrame:TweenPosition(UDim2.new(0,0,1,0), "Out", 1)
wait(0.8)
Cs.UpperFrame:TweenPosition(UDim2.new(0,0,0,-150), "Out", 1)
Cs.LowerFrame:TweenPosition(UDim2.new(0,0,1,0), "Out", 1)
wait(1.1)
warn("T R I G G E R E D    B O I")
script:Destroy()
end)

BTW: I'm a noob scripter

3 comments

0

you can really only tween guis from the client in game

0

Then could you explain how to do it?

0

As a general rule, any time you run into a problem where "it works in studio but not in game" it's most likely a client/server problem. I strongly recommend reading the wiki page on the Client Server Model to learn how the filtering enabled system works. Some things like GUI should be handled from the client, while other things like data and badges should be handled from the server.

1 answer

✓ Accepted answer

###StarterGui vs PlayerGui

The StarterGui service is a list of a list of GUIs (Graphical User Interface)s that will replicate to the player when they join. The problem here is thtat you are editing the GUI in StarterGui, rather then the one in PlayerGui.

###Solution


--[[
	READ ME
	READ ME
	READ ME

	I've edited this script to work with FilteringEnabled. Here is what to do:

	1) Edit the "partLocation" variable to the part you want touched (example: game.Workspace.Part)
	2) Paste this code into a LocalScript
	3) Put the LocalScript into StarterGui or any GUI.

	Also you are missing the Transition Style arguement, so I filled it in for you.
--]]
local plr = game.Players.LocalPlayer
local SG = plr:WaitForChild("PlayerGui")
local Cs = SG.CutScenes

local partLocation -- EDIT THIS

partLocation.Touched:Connect(function()

Cs.UpperFrame:TweenPosition(UDim2.new(0,0,0,-35), "Out", "Quad", 1) 
Cs.LowerFrame:TweenPosition(UDim2.new(0, 0,0.793, 0),  "Out", "Quad", 1)
wait(6.25)
Cs.TransPArencyFrame:TweenPosition(UDim2.new(0,0,0,0), "Out", "Quad", 1)
wait(1.6)
Cs.TransPArencyFrame:TweenPosition(UDim2.new(0,0,1,0), "Out", "Quad", 1)
wait(0.8)
Cs.UpperFrame:TweenPosition(UDim2.new(0,0,0,-150), "Out", "Quad", 1)
Cs.LowerFrame:TweenPosition(UDim2.new(0,0,1,0), "Out", "Quad", 1)
wait(1.1)
warn("T R I G G E R E D    B O I")
script:Destroy()
end)

3 comments

0

The reason it works in studio is because studio doesn't employ the client/server algorithm while studio only uses a local client/client algorithm

0

@misi algorithm? the problem is that he's trying to do something from the server that can only be done on the client, and green did a fine job fixing it.

0

I know why it doesn't work, but that was irrelevant to the question. I put in that I fixed it so it works w/ FE so he can research it and try it on his own

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