I have written this code, but it doesn’t seem to work or provide any output. Perhaps you could help me by reviewing it or writing some alternative code. Thank you in advance for your kind assistance!
Do you mind reformatting it? It’s a bit difficult to read.
I’m guessing you want the wipers to work when G is pressed.
You have some if statements in that section of code (It’s a bit hard to read since you only formatted some of your code. Use the prints I’ve put in below to see if the variables are actually what you’d expect for the code to run successfully.
Also, why does the setupAnimation function only seem to be calling for the kickAnimation?
– G tuşunu dinleyerek animasyonu başlat
game:GetService(“UserInputService”).InputBegan:Connect(function(input, gameProcessed)
print("gameProcessed = ", gameProcessed)
if gameProcessed then return end
print("input.KeyCode = ", input.KeyCode)
if input.KeyCode == Enum.KeyCode.G then
print("rig = ", rig, " setupRig() = ", setupRig())
if not rig and setupRig() then
setupAnimation()
end
startAnimation()
end
end)
local toolbar = plugin:CreateToolbar("Driver Animation Tool")
local button = toolbar:CreateButton("Activate Animation", "Start/Stop Driver Animation", "")
local kickAnimationId = "rbxassetid://censored"
local vehicleModel = nil -- Araç modeli buraya atanacak
local rig = nil -- Rig burada tanımlanacak
local kickAnimationTrack = nil
-- Araç modelini seçmek için bir seçim aracı
button.Click:Connect(function()
if not vehicleModel then
local selection = game.Selection:Get()[1]
if selection and selection:IsA("Model") then
vehicleModel = selection
print("Araç modeli seçildi:", vehicleModel.Name)
else
warn("Lütfen bir araç modeli seçin.")
end
else
print("Araç modeli zaten seçilmiş:", vehicleModel.Name)
end
end)
-- Rig'i araç modelinin içinde bul
local function setupRig()
if not vehicleModel then
warn("Araç modeli seçilmedi. Lütfen önce bir araç modeli seçin.")
return false
end
local body = vehicleModel:FindFirstChild("body")
if body then
local silecek = body:FindFirstChild("Silecek")
if silecek then
rig = silecek:FindFirstChild("riglendirildi")
if rig then
print("Rig başarıyla bağlandı:", rig.Name)
return true
else
warn("riglendirildi bulunamadı.")
end
else
warn("Silecek bulunamadı.")
end
else
warn("body bulunamadı.")
end
return false
end
-- Animasyon nesnelerini oluştur
local function setupAnimation()
if not rig then return end
-- AnimationController ve Animator ekle
local animationController = rig:FindFirstChildOfClass("AnimationController")
if not animationController then
animationController = Instance.new("AnimationController")
animationController.Parent = rig
end
local animator = animationController:FindFirstChildOfClass("Animator")
if not animator then
animator = Instance.new("Animator")
animator.Parent = animationController
end
-- Animasyonu yükle
local kickAnimation = Instance.new("Animation")
kickAnimation.AnimationId = kickAnimationId
kickAnimationTrack = animator:LoadAnimation(kickAnimation)
if not kickAnimationTrack then
warn("Animasyon yüklenemedi. Lütfen animasyon ID'sini kontrol edin.")
else
print("Animasyon başarıyla yüklendi.")
end
-- Marker'ı dinle
kickAnimationTrack:GetMarkerReachedSignal("KickEnd"):Connect(function(paramString)
print("KickEnd işaretine ulaşıldı: " .. paramString)
kickAnimationTrack:Stop()
end)
end
-- Animasyonu başlat/durdur
local function startAnimation()
if kickAnimationTrack then
if kickAnimationTrack.IsPlaying then
kickAnimationTrack:Stop()
print("Animasyon durduruldu.")
else
kickAnimationTrack:Play()
print("Animasyon başlatıldı.")
end
else
warn("Animasyon başlatılamadı. Lütfen rig'in doğru kurulduğundan emin olun.")
end
end
-- G tuşunu dinleyerek animasyonu başlat
game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.G then
if not rig and setupRig() then
setupAnimation()
end
startAnimation()
end
end)
Please respond to the post you’re replying to, not your original post. If you do then we don’t get good notifications.
So when you put the print statements in did you get any information from the prints that tells you something isn’t working right?