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

FE Problem: My GUI tween won't work?

It works in studio but it doesn't work in the actual server, I have the RemoteEvent within ReplicatedStorage, the a,b,c,d,e arguments are based on the tween properties, the server-sided script is inside ServerScriptService while the local script is located within the button.

Server Script

game.ReplicatedStorage.open.OnServerEvent:connect(function(player, a,b,c,d,e)
	player.PlayerGui:WaitForChild("main").sidebar:TweenPosition(a,b,c,d,e)
end)

Local Script

local button = script.Parent
local debounce = true

button.MouseButton1Click:connect(function()
	if debounce == true then
		game.ReplicatedStorage.open:FireServer(UDim2.new(0,-80,1,-190),"In","Back",1)
		debounce = false
	else
		game.ReplicatedStorage.open:FireServer(UDim2.new(0,0,1,-190),"In","Back",1)
		debounce = true
	end
end)

Thanks in advance!

3 comments

0

its better to do Tweening locally, for your event you have not waited for the "open" object so it may not exist yet. Are there any errors?

0

The arguments are fired within the local script with the supposed positions, there are no errors as far as I'm concerned.

0

<3

1 answer

✓ Accepted answer

Server Scripts Can't access ReplicatedStorage

Similarly, LocalScripts Can't access ServerStorage or ServerScriptService. This is due to security reasons. Server sided scripts can't access ReplicatedStorage and ReplicatedFirst. There is a second problem with your scripts as well.

Server Sided Scripts Cant Access PlayerGui. To fix this problem use a local script to do almost Anything to do with the player's GUI.

I highly suggest reading up on this about Filtering enabled.

Now for your code,

Now this might not work because there are a few details I'm missing but here's what would seem like what would fix your scripts.

Step one, You only need to use one script for what is shown. It can all be done within the second script. The local script.

Step two, Combine the scripts. Now you haven't given us the script that sends the remote event, but here's Something of what your script should look like,

--LocalScript
local button = script.Parent
local debounce = true
local player = game.Players.LocalPlayer

button.MouseButton1Click:connect(function()
    if debounce == true then
        debounce = false
player.PlayerGui:WaitForChild("main").sidebar:TweenPosition(UDim2.new(0,-80,1,-190),"In","Back",1)
        
    else
    
player.PlayerGui:WaitForChild("main").sidebar:TweenPosition((UDim2.new(0,0,1,-190),"In","Back",1)
        debounce = true
    end
end)

The code block is acting weird for me so the tabbing might be off. Now this might not work. This is to give you an idea.

That's about all. Good Luck!

2 comments

0

Oh, thanks! I thought that local scripts are dependent on server scripts, I guess there are few exceptions.

0

Scripts can access ReplicatedStorage... That's the reason it's Replicated.

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