RemoteEvent only fires Once

Hey, I am having trouble with my script, the event fires and works perfectly fine the first time, but after that nothing happens at all, it cannot be fired anymore, does anyone know why? Here is my script,

local RS = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local RemoteEvent = RS:WaitForChild("ShopEnter")


local function functionName(player)
	local PlayerGui = player:WaitForChild("PlayerGui")
	local ScreenGui = PlayerGui:WaitForChild("Shop")
	local object = ScreenGui:WaitForChild("Frame")
	
	local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out)
	local tween = TweenService:Create(object, tweenInfo, {Position = UDim2.new(0,0,0,0)})
	tween:Play()
	
	workspace.Shop.Boom.Music:Pause()
	workspace.Shop.Boom.Bell:Play()
end
RemoteEvent.OnServerEvent:Connect(functionName)

Thank you!

What is the point of the remote event here? From what I’m seeing, you can do everything on the client (it also is more visually appealing too!)

Its a shop gui, when you use a proximity prompt it fires this event and the gui slides onto the screen.

Can you send us the ProximityPrompt script too? Thanks

you dont even need a remote event for that i think?

Could you also show the local scirpt firing the remote event?

local ProximityPrompt = workspace.Interaction.Shop.ProximityPrompt
ProximityPrompt.Triggered:Connect(function(player)
	game.ReplicatedStorage.ShopEnter:FireServer(player)
	ProximityPrompt.MaxActivationDistance = 0
	wait(3)
	ProximityPrompt.MaxActivationDistance = 15
end)

Gotcha! Again, I don’t think a remote event is needed for this case.

You can do something like:

local ProximityPrompt = Prompt -- Your proximity prompt
local ShopFrame = ScreenGui:WaitForChild("Frame") -- Your shop frame
local TweenService = game:GetService("TweenService")

ProximityPrompt.Triggered:Connect(function()
    --<< Prompt has been triggered >>--
    TweenService:Create(ShopFrame, TweenInfo.new(0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out), {Position = UDim2.new(0, 0, 0, 0}):Play()
end)
1 Like

Adding on to this, maybe the client reacts to other people triggering the prompt. Maybe, I’m not sure. But the event should be connected on the server and the remote event isn’t needed, like you said.

If you mean as in, it only “drops” into place. You’ll need one that will reverse that on exit. Maybe

Yeah, exiting the GUI sends it back to its original position with tweens.

Thank you, I will try this now.

You’re right. I forgot to mention that the triggered event returns the player as well! If you want to avoid other players triggering the tween, you can simply add an if then state like so:

local ProximityPrompt = Prompt -- Your proximity prompt
local ShopFrame = ScreenGui:WaitForChild("Frame") -- Your shop frame
local TweenService = game:GetService("TweenService")
local Player = game:GetService("Players").LocalPlayer

ProximityPrompt.Triggered:Connect(function(Plr)
    --<< Prompt has been triggered >>--
    if (Plr ~= Player) then return end
    TweenService:Create(ShopFrame, TweenInfo.new(0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out), {Position = UDim2.new(0, 0, 0, 0}):Play()
end)
1 Like

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