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

Tween isn't working and there is nothing in output. What's the error?

So. I was trying to make this thing when you press the key, E on your keyboard. The door tweens. But it doesn't show anything in the output. Here is the code, this code is written in a regular script, not a local script, not a module script.

	local UIS = game:GetService("UserInputService")
	local MaxDistance = 5
	UIS.InputBegan:Connect(function(input, player)
		if input.KeyCode == Enum.KeyCode.E then
		local HumanoidRootPart = player.Character.HumanoidRootPart
		local MainPart = game.Workspace.MainPart
		local TweenService = game:GetService("TweenService")
		if HumanoidRootPart.Position - MainPart.Position.Magnitude <= MaxDistance then
			local TweenInformation = TweenInfo.new(
				3,
				Enum.EasingStyle.Sine,
				Enum.EasingDirection.Out,
				0,
				true,
				1
			)
			local Properties = {
				Size = Vector3.new(6.27, 0.05, 2);
			}
			local Tween = TweenService:Create(MainPart,TweenInformation,Properties)
			Tween:Play()
		end
		end
	end)

2 comments

0

"if HumanoidRootPart.Position - MainPart.Position.Magnitude <= MaxDistance then" -> "if (HumanoidRootPart.Position - MainPart.Position).Magnitude <= MaxDistance then"

0

Another error is your player. The 2nd argument of InputBegan:Connect is not player, is gameProcessed.

1 answer

InputBegan is an event that fires only on the client, not the server, and the second argument of the InputBegan event is not the player.

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