Hello developers! I hope you are having a great day!
I have a problem with tires rotating like this:
Whenever I go into the go-kart.
If I don’t use this script:
local debounce = false
function onChildAdded(hit)
if debounce == false then
local orentation = script.Parent.Wheels.RR.Parts.Rim.Orientation
if hit.Name == "SeatWeld" then
local human = hit.part1.Parent:FindFirstChild("Humanoid")
if (human ~= nil) then
local plr = game.Players:GetPlayerFromCharacter(human.Parent)
if plr then
local kartFolder = plr:FindFirstChild("Kart")
if kartFolder then
local wheels = kartFolder:WaitForChild("Tires")
local wheelsHolder = game.ReplicatedStorage.Tires
local selected = nil
for i, wheel in pairs(wheels:GetChildren()) do
if wheel:IsA("BoolValue") then
if wheel.Value == true then
selected = wheel.Name
end
end
end
if selected ~= nil then
local found = wheelsHolder:FindFirstChild(selected)
if found then
local fr = script.Parent.Wheels.FR
for i, v in pairs(fr.Parts:GetDescendants()) do
v:Destroy()
end
for i, ch in pairs(found:GetDescendants()) do
if ch:IsA("BasePart") then
local cl = ch:Clone()
cl.Parent = script.Parent.Wheels.FR.Parts
cl.Orientation = orentation
local weld = Instance.new("Weld", cl)
weld.Part0 = cl
weld.Part1 = script.Parent.Wheels.FR
cl.CFrame = script.Parent.Wheels.FR.CFrame
cl.Anchored = false
end
end
script.Parent.Wheels.FR.Anchored = false
end
local fl = script.Parent.Wheels.FR:Clone()
for i, v in pairs(script.Parent.Wheels.FL.Parts:GetDescendants()) do
v:Destroy()
end
for i, ch in pairs(found:GetDescendants()) do
if ch:IsA("BasePart") then
local cl = ch:Clone()
cl.Parent = script.Parent.Wheels.FL.Parts
cl.Orientation = orentation
local weld = Instance.new("Weld", cl)
weld.Part0 = cl
weld.Part1 = script.Parent.Wheels.FL
cl.CFrame = script.Parent.Wheels.FL.CFrame
cl.Anchored = false
end
end
script.Parent.Wheels.FL.Anchored = false
local rl = script.Parent.Wheels.FR:Clone()
for i, v in pairs(script.Parent.Wheels.RL.Parts:GetDescendants()) do
v:Destroy()
end
for i, ch in pairs(found:GetDescendants()) do
if ch:IsA("BasePart") then
local cl = ch:Clone()
cl.Parent = script.Parent.Wheels.RL.Parts
cl.Orientation = orentation
local weld = Instance.new("Weld", cl)
weld.Part0 = cl
weld.Part1 = script.Parent.Wheels.RL
cl.CFrame = script.Parent.Wheels.RL.CFrame
cl.Anchored = false
end
end
script.Parent.Wheels.RL.Anchored = false
local rr = script.Parent.Wheels.FL:Clone()
for i, v in pairs(script.Parent.Wheels.RR.Parts:GetDescendants()) do
v:Destroy()
end
for i, ch in pairs(found:GetDescendants()) do
if ch:IsA("BasePart") then
local cl = ch:Clone()
cl.Parent = script.Parent.Wheels.RR.Parts
cl.CFrame = script.Parent.Wheels.RR.CFrame
cl.Orientation = orentation
local weld = Instance.new("Weld", cl)
weld.Part0 = cl
weld.Part1 = script.Parent.Wheels.RR
cl.Anchored = false
end
end
script.Parent.Wheels.RR.Anchored = false
end
end
end
end
end
end
end
script.Parent.DriveSeat.ChildAdded:Connect(onChildAdded)
The tires are just normal:
Solutions I tried:
- I tried matching the Orientation on all the parts, matching them on the normal kart
- I tried setting the oreintation in the script before and after the welding operation
- I used WeldConstraints, which break the kart
If you can help, please let me know. Thank you, WE