This evening I encountered an issue with my script. As a modeler, I don’t have much experience with scripting so I myself am not able to understand the problem. If anyone could provide any feedback or suggestions regarding what is wrong with the script, that would be of great help. Thank you.
local tweenService = game: GetService ("TweenService")
local spleefParts = game.Workspace.spleefParts:GetChildren()
local function spleefTouched()
tweenService: Create(spllefPart, TweenInfo.new(.6, Enum.EasingStyle.Linear), (Transparency = 1):Play()
wait(.5)
spleefPart.CanCollide = false
)
end
for i, spleefPart in pairs(spleefParts) do
spleefPart.Touched:Connect(function)(hit)
local humanoids = hit.Parent:FindFirstChild("Humanoid")
If humanoid then
spleefTouched(spleefPart)
end
end)
end
The script isn’t formatted correctly. Here is the fixed one:
local tweenService = game:GetService("TweenService")
local spleefParts = game.Workspace.spleefParts:GetChildren()
local function spleefTouched(spleefPart) -- include the argument you sent in the parentheses
tweenService:Create(spleefPart, TweenInfo.new(.6, Enum.EasingStyle.Linear), {Transparency = 1}):Play()
-- the third argument (Transparency) is wrapped in a table
task.wait(.5) -- fun fact: this is more efficient than wait()!
spleefPart.CanCollide = false
end
for i, spleefPart in pairs(spleefParts) do
spleefPart.Touched:Connect(function(hit) -- fixed this
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then -- "if" is not capitalized. humanoid needs to correlate with the local defined above
spleefTouched(spleefPart)
end
end)
end
I was able to create a much more simple script that worked very well. Thank you very much @neweve2323 for the helpful notes you left within the script. It definitely helped me understand the script better.