Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to do changed event?

Asked by
JJ_B 250 Moderation Voter
9 years ago

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?

1 answer

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

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)
0
Thanks. JJ_B 250 — 9y
Ad

Answer this question