Hello developers! I am currently making a system which when the player touches a part, a shelf falls over. But i keep getting an error which says “Attempt to index nil with “primarypart””. The local script is in startergui. If anybody could help me, it would be appreciated!
Script that detects when a player touches the part
if game.Players:GetPlayerFromCharacter(hit.Parent) then
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("HumanoidRootPart") then
local person = game.Players:GetPlayerFromCharacter(hit.Parent)
local shelf1 = script.Parent.Parent.Shelf1
game.ReplicatedStorage.TriggerTweens:FireClient(person, shelf1)
end
end
end)
Local script that tweens (error is in here)
local tweenService = game:GetService("TweenService")
local plr = game.Players.LocalPlayer
local function Fall(shelf1)
local fall = tweenService:Create(shelf1.PrimaryPart, TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0), -- error here
{Rotation = -90})
fall:Play()
end
game.ReplicatedStorage.TriggerTweens.OnClientEvent:Connect(function(plr, shelf1)
Fall(shelf1)
end)