Activate Tween with a bindable event

  1. What do you want to achieve?
    I want too make the tween play with a bindable event.

  2. What is the issue?
    The event fires but the local script doesn’t seem too pick it up.

  3. What solutions have you tried so far?
    Asking in discord servers, using other’s code, and messing around with it.

First script that fires the event

local replicatedStorage = game:GetService("ReplicatedStorage")
local dialogUpEvent = replicatedStorage:WaitForChild("dialogUp")

local TweenService = game:GetService("TweenService")
local frame = script.Parent

local targetPosition = UDim2.new(0.161, 0, 0.845, 0) -- Move the frame up by 50% of its size

-- Define the tween properties
local tweenInfo = TweenInfo.new(
	2, -- Duration (in seconds)
	Enum.EasingStyle.Quad, -- Easing style (you can experiment with different styles)
	Enum.EasingDirection.Out, -- Easing direction
	0, -- Delay (in seconds)
	false, -- Reverses the tween
	0 -- Repeats (set to 0 for no repeats)
)

-- Create the tween
local tweenUP = TweenService:Create(frame, tweenInfo, { Position = targetPosition })

-- Listen for the event to trigger the tween
dialogUpEvent.Changed:Connect(function()
	print("Received dialogUpEvent. Playing tween.")
	tweenUP:Play()
end)


Local script in UI

local replicatedStorage = game:GetService("ReplicatedStorage")
local dialogUpEvent = replicatedStorage:WaitForChild("dialogUp")

local TweenService = game:GetService("TweenService")
local frame = script.Parent

local targetPosition = UDim2.new(0.161, 0, 0.845, 0) -- Move the frame up by 50% of its size

-- Define the tween properties
local tweenInfo = TweenInfo.new(
	2, -- Duration (in seconds)
	Enum.EasingStyle.Quad, -- Easing style (you can experiment with different styles)
	Enum.EasingDirection.Out, -- Easing direction
	0, -- Delay (in seconds)
	false, -- Reverses the tween
	0 -- Repeats (set to 0 for no repeats)
)

-- Create the tween
local tweenUP = TweenService:Create(frame, tweenInfo, { Position = targetPosition })

-- Listen for the event to trigger the tween
dialogUpEvent.Changed:Connect(function()
	print("Received dialogUpEvent. Playing tween.")
	tweenUP:Play()
end)

wait(5)
tweenUP:Play()


You seem to be using .Changed for the connection, .Changed fires when the instance property is changed, instead you should try using .Event

And if you’re going from server to client (normal script to local script) use a remote event. In which you’ll have to use .OnClientEvent to detect from server to client, and .OnServerEvent for client to server

Where should i put the .onClientEvent and .onServerEvent?

To use onclient or onserver you simply need a RemoteEvent and path to it in the script.
To check when client fires server

local Remote=game:GetService('ReplicatedStorage'):WaitForChild('RemoteEvent')

Remote.OnServerEvent:Connect(function(player_that_fired_remote, arguments_passed_with_fire)
    print('Player '..player_that_fired_remote.Name..' fired the remote!')
end

--to fire a client
Remote:FireClient(player_instance,'hello!')

--to fire every client
Remote:FireAllClients('hello everyone!')

To check when server fires client

local Remote=game:GetService('ReplicatedStorage'):WaitForChild('RemoteEvent')

Remote.OnClientEvent:Connect(function(arguments_passed)
    print(arguments_passed)
end

--to fire the server
Remote:FireServer('hello!')
1 Like

I got the script too work thank you!!

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