Hello!!! I am completely new to writing Topic. Please let me know if I’m doing anything wrong… I’m also new to scripting.
- What do you want to achieve?
I want to make all seat transparency change to 0 when local client touched a seat and all seat transparency to 1 when player stands…
- What is the issue?
It causes error
14:57:24.824 Workspace.1_2cx.Animations:7: attempt to index nil with 'Connect' - Client - Animations:7
14:57:24.824 Stack Begin - Studio
14:57:24.824 Script 'Workspace.1_2cx.Animations', Line 7 - Studio - Animations:7
14:57:24.825 Stack End - Studio
This is my script I wrote. It’s LocalScript. I don’t know I wrote correct codes, I inserted in StarterCharacterScripts… and Animatons is folder that include seats
local Anims = workspace.Animations
local Seats = Anims:GetChildren()
local Plr = game.Players.LocalPlayer
local player = game:GetService("Players")
for i, child in ipairs(Seats) do
Seats.Touched:Connect(function()
if Plr:FindFirstChildWhichIsA("Humanoid")then
Seats.Transparency = 1
end
end)
Seats.TouchEnded:Connect(function(hit)
if Plr:FindFirstChildWhichIsA("Humanoid")then
Seats.Transparency = 0
end
end)
end
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Yes. I have checked DevHub multiple times, and have also checked other websites too. I have tried everything I can.
-- This is an example Lua code block
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.