Why my script is not working?

Ok so, this time im trying to make an jewel that changes it transparency every time the RunService hearbeats, but it’s giving me this error
image

Code:

    local jewel = game.Workspace.Museum.MuseumItems.JewelCase.Jewel

    game:GetService("RunService").Heartbeat:Connect(function(jewel)
    	if jewel.Reflectance < 0.1 then
    		jewel.Transparency = 0.6 + 0.2 * math.cos(tick() * 8);
    		return;
    	else
    		jewel.Transparency = 1;
    	end
    end)

The Heartbeat event returns deltaTime, not a jewel object.

https://developer.roblox.com/en-us/api-reference/event/RunService/Heartbeat

You can possibly just remove ‘jewel’ from the function arg. Also, you don’t need semicolons.

    local jewel = game.Workspace.Museum.MuseumItems.JewelCase.Jewel

    game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
    	if jewel.Reflectance < 0.1 then
    		jewel.Transparency = 0.6 + 0.2 * math.cos(tick() * 8)
    		return
    	else
    		jewel.Transparency = 1
    	end
    end)
1 Like

Hey! Thanks for that information <3 You solved my problem, it’s working perfectly fine!

1 Like