Serverscriptservice Tweening

I am working on an “elevator game” and this issue is not helping me.
I have tried tweening a part from serverscriptservice using BindableEvents, RemoteEvents, and also just for the sake of it, doing it directly from the serverscript.
Even with BindableEvents I can’t get it to work.
image

I am trying to get “ElevatorHandler” to tween “left”.

this is “ElevatorHandler”

ServerStorage = game:GetService("ServerStorage")
ReplicatedStorage = game:GetService("ReplicatedStorage")
Players = game:GetService("Players")

Maps = ServerStorage:WaitForChild('Maps'):GetChildren()
Status = ReplicatedStorage:WaitForChild('Status')
local Remote = game:GetService('ReplicatedStorage'):WaitForChild('Tweener') -- this is the bindableEvent

while true do

	--inter

	local Countdown = 5

	repeat wait(1)
		Countdown = Countdown - 1

		Status.Value = ''..Countdown
	until Countdown <= 0

	--Choose the map.

	Status.Value = '0'

	local ChosenMap = Maps[math.random(1, #Maps)]:Clone()
	local Spawns = ChosenMap:FindFirstChild('Spawns'):GetChildren()
	local RandomSpawn = Spawns[math.random(1, #Spawns)]

	wait(5)

	ChosenMap.Parent = workspace
	Status.Value = '0'

	wait(2)

	--this is where i need the doors to open.
	
	Remote:Fire() -- my attempt at making a bindableEvent fire for the tween.

	for _, Player in pairs(Players:GetChildren())do
		if Player.Character and Player.Character:FindFirstChild('Humanoid') then
			Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
		end
	end

	Countdown = 5 --the floor starts

	repeat wait(1)
		Countdown = Countdown - 1

		Status.Value = '0'..Countdown
	until Countdown <= 0

	Countdown = 5 -- Game Time, ten seconds so the video isn't long, make this as long as you want.

	repeat wait(1)
		Countdown = Countdown - 1

		Status.Value = 'ingame: '..Countdown
	until Countdown <= 0

	--despawn

	for _, Player in pairs(Players:GetChildren())do
		if Player.Character and Player.Character:FindFirstChild('Humanoid') then
			Player.Character.Humanoid:TakeDamage(2000)
		end
	end

	ChosenMap:Destroy()

	Status.Value = 'rounds ended'

	wait(4)

end

This is the script inside the “Doors” model which recieves the event, and tries to tween.

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

Remote.OnClientEvent:Connect(function()
	script.Parent.left:Destroy()
end)

^ I made it destroy the part to check if the event was even working, it was not.
There originally was a Tween.

Any help would be so much appreciated!

2 Likes

Hey!
What does your script look like?

2 Likes

I have edited the post and added in the scripts.

1 Like

You’re actually not tweening anything, you’re just destroying the part.

1 Like

Oh, sorry, it was just to check if it was even doing anything.
It didn’t even destroy the part.

1 Like

you’re just destroying the part when the client receives it

1 Like

The remote event isn’t working because only normal script are working in the workspace, and the event is fired by the server and should be received by the client.

So you have to receive it from a local script in StarterPlayerScript

local Remote = game:GetService('ReplicatedStorage'):WaitForChild('Tweener')
local Doors = workspace:WaitForChild("Doors")
local Left = Doors and Doors:WaitForChild("left")
local Right = Doors and Doors:WaitForChild("right")

Remote.OnClientEvent:Connect(function()
	Left:Destroy() -- Change to tweenservice next
end)
1 Like

bindable events for server - server or client - client communication. If you want the client to tween it, you will use remote event and than put player at :FireClient(“here”). You are using OnClientEvent on a bindable event.

Apparently my code did not work after a point because my folder with the floors/maps was empty, i added maps and made something like your script and worked!
Thank you so much for the help!

1 Like

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