Hello again, so I was trying to make a system where you can rotate your tower while trying to place it by pressing Q or R It works fine but I wanted to add animations to it so I used TweenService to do it but an error shows up saying what the title said how do I fix this?
RunService.RenderStepped:Connect(function()
if TowerToSpawn then
local Result = MouseRaycast({TowerToSpawn})
for i, Borders in ipairs(workspace.Map.Towers:GetDescendants()) do
if Borders:IsA("Part") and Borders.Name == "Border" then
Borders.Transparency = 0.5
CanPlace = false
end
end
if Result and Result.Instance then
if Result == "AllowedArea" or Result.Instance.Name == "AllowedArea" then
CanPlace = true
OutlineColor(Color3.fromRGB(255, 255, 255))
else
CanPlace = false
OutlineColor(Color3.fromRGB(255, 0, 0))
end
local X = Result.Position.X
local Y = Result.Position.Y + TowerToSpawn.Humanoid.HipHeight + (TowerToSpawn.PrimaryPart.Size.Y /2)
local Z = Result.Position.Z
local SpinInfo = TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local RotateAnimation = TweenService:Create(TowerToSpawn.PrimaryPart, SpinInfo, {CFrame.new(X, Y, Z) * CFrame.Angles(0, math.rad(Rotation), 0)})
RotateAnimation:Play()
SoundsFolder.Rotate:Play()
end
end
end)