I’m trying to make a car that has the abillity to release an oil slick but I’m having issues.
I’m trying to make it tween one way and although I’ve found how to do that, when the car rotates it tweens the way I don’t want it to tween.
Overall I think the whole code needs to be rewritten but I just don’t know how
local replicatedstorage = game:GetService("ReplicatedStorage")
local tweenService = game:GetService("TweenService")
local oilslick = replicatedstorage:WaitForChild("OilSlick")
local oil = replicatedstorage:WaitForChild("Oil")
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local function CreateResizeTween(instance, tweenInfo, normalId, deltaAmount)
local deltaSize = Vector3.fromNormalId(normalId) * deltaAmount
deltaSize = Vector3.new(math.abs(deltaSize.X), math.abs(deltaSize.Y), math.abs(deltaSize.Z)) * math.sign(deltaAmount) -- if deltaAmount is less than 0 it will reduce the size, else it will increase the size
local deltaPosition = Vector3.fromNormalId(normalId) * deltaAmount
return tweenService:Create(instance, tweenInfo, {Position = instance.Position + deltaPosition / 2; Size = instance.Size + deltaSize})
end
oilslick.OnServerEvent:Connect(function(plr, position)
if script.Parent.DriveSeat.Occupant == plr.Character.Humanoid then
script.Parent.CarConfig.Oil.Value -= 500
script.Parent.Brake.Value = true
local instance = oil:Clone()
instance.CFrame = position
instance.Parent = workspace
CreateResizeTween(instance, info, Enum.NormalId.Back, 30):Play()
end
end)
The behaviour I want it to do is to release in the opposite direction of the car
