I am in this game trying to make a animation with a arm sticking out when i put it into this chair it makes the arm curve here is the script note its in a chair with the animation:
seat = script.Parent
function added(child)
if (child.className==“Weld”) then
human = child.part1.Parent:FindFirstChild(“Humanoid”)
if human ~= nil then
anim = human:LoadAnimation(seat.sitanim)
anim:Play()
end
end
end
function removed(child2)
if anim ~= nil then
anim:Stop()
anim:Remove()
end
end
Is this the entire script? If not, pleases show us the entire script, or anything relating to this code.
Anything related to scripting support goes inside of scripting support, even if you’re using it for something like art design. (correct me if I’m wrong)
Just to clear some things up. When you put the arm inside the chair in explorer, it makes the arm curved? But when its outside of the chair, its not curved?
This should work if you put your animation in there.
local seat = script.Parent
local seatanim = --your animation
local anim
local function added()
if seat:FindFirstChildOfClass("Weld") then
local child = seat:FindFirstChildOfClass("Weld")
local human = child.Part1.Parent:FindFirstChild("Humanoid")
if human ~= nil then
anim = human:LoadAnimation(seatanim)
anim:Play()
end
end
end
local function removed()
if anim ~= nil then
anim:Stop()
anim:Remove()
end
end
seat.ChildAdded:Connect(function()
added()
end)
seat.ChildRemoved:Connect(function()
removed()
end)
Sorry for late response. I’m not used to using seats.
Script
local seat = script.Parent
local seatanim = seat.Animation1
local function added()
if seat:FindFirstChildOfClass("Weld") then
local child = seat:FindFirstChildOfClass("Weld")
local human = child.Part1.Parent:FindFirstChild("Humanoid")
if human ~= nil then
local char = human.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
local sitanimation = human.Parent.Animate.sit.SitAnim
local oldsitanimation = "http://www.roblox.com/asset/?id=2506281703"
sitanimation.AnimationId = seatanim.AnimationId
wait(1)
game.ReplicatedStorage.RemoteEvent:FireClient(plr, oldsitanimation)
end
end
end
seat.ChildAdded:Connect(function()
added()
end)
Local Script (parented to PlayerGui)
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local human = char:WaitForChild("Humanoid")
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(oldanim)
local AnimationTracks = char.Humanoid:GetPlayingAnimationTracks()
for i, v in pairs(AnimationTracks) do
v:Stop()
end
char.Animate.sit.SitAnim.AnimationId = oldanim
local sitanim = char.Animate.sit.SitAnim
local newanim = human:LoadAnimation(sitanim)
newanim:Play()
newanim.Looped = true
end)
Create a remote event and name it “Remote” and parent it to ReplicatedStorage