I'm not entirely sure how to use the changed event, but I made this script to make a sound and change a decal's transparency when a value is changed. Here's the script:
function warp(value) script.Parent.Parent.db = false game.Workspace.StarshipWiz.Helm.Part.warp1:Play() game.Workspace.StarshipWiz.warp.Decal.Transparency = 0 wait(12) script.Parent.Parent.db = true game.Workspace.StarshipWiz.Helm.Part.warp2:Play() game.Workspace.StarshipWiz.warp.Decal.Transparency = 1 end game.Workspace.StarshipWiz.Planet.Changed(warp)
The output says, "Workspace.StarshipWiz.Planet.Script:11: attempt to call field 'Changed' (a userdata value)"
Can someone tell me how to rectify this?
The parentheses after Changed
says to the script that Changed
is a function that you're calling with the parentheses. But this is wrong, as it's an event, thus the error.
What you want to do is connect the Changed
event to the warp
function, so that it will be called every time the event is fired.
game.Workspace.StarshipWiz.Planet.Changed:connect(warp)