Hello!
I’m writing a script that places a platform under your feet and follows your character but the Y only changes when you press Q and E. When you hold Q and E down it makes the platform move up and down but it was very clunky making it move 1 stud every 0.2 seconds. So now I’m trying to move the platform up and down with tweens. I’ve never used tweens before but followed a youtube video. Still no success. Nothing happens when I press Q and there are no errors in the console.
local platformMenu = options.Platform
local platformToggle = platformMenu.TextButton
local platformInput = platformMenu.TextBox
local platformEnabled = false
local function PlatformFunc()
local platform = Instance.new("Part")
if platformEnabled then
local charPos = Player.Character.HumanoidRootPart
platform.Color = Color3.fromRGB(255, 0, 0)
platform.Size = Vector3.new(0.2,5,5)
platform.Anchored = true
platform.Material = Enum.Material.Neon
platform.CFrame = charPos.CFrame * CFrame.new(0, -2.5, 0)
platform.Shape = Enum.PartType.Cylinder
while platformEnabled == true do
task.wait()
platform.Parent = workspace
local charRoot = Player.Character:WaitForChild("HumanoidRootPart")
platform.CFrame = CFrame.new(charPos.CFrame.X, platform.CFrame.Y, charPos.CFrame.Z) * CFrame.Angles(0,0,math.rad(90))
if platformEnabled == false then
platform:Destroy()
end
end
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local tweenGoal = {platform.CFrame * CFrame.new(platformInput.Text, 0, 0)}
local platformControl = TweenService:Create(platform,tweenInfo,tweenGoal)
local function isKeyHeld(input)
while UIS:IsKeyDown(Enum.KeyCode.Q) and platformEnabled do
platformControl:Play()
--platform.CFrame = platform.CFrame * CFrame.new(platformInput.Text, 0, 0)
--Player.Character.HumanoidRootPart.CFrame = Player.Character.HumanoidRootPart.CFrame * CFrame.new(0 , platformInput.Text, 0)
wait(0.2)
end
while UIS:IsKeyDown(Enum.KeyCode.E) and platformEnabled do
platform.CFrame = platform.CFrame * CFrame.new(- platformInput.Text, 0, 0)
Player. Character.HumanoidRootPart.CFrame = Player.Character.HumanoidRootPart.CFrame * CFrame.new(0 , - platformInput.Text, 0)
wait(0.2)
end
end
UIS.InputBegan:Connect(isKeyHeld)
end
end