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

why won't this script function on the change?

Asked by 4 years ago

So this is suppose to function when the puck is covered and then the name changes. script:

while true do
    wait(0.1)
if game.Workspace.Puck.Name == 'glovedpuck'  then
    game.Workspace.glovedpuck.Anchored = true
    game.Workspace.GameSounds.Whistle:Play()
end
end

2 answers

Log in to vote
0
Answered by 4 years ago

This may work. I have tested it and it worked.

local Puck = workspace.Puck
local Whistle = workspace.GameSounds.Whistle

Puck.Changed:Connect(function(property)
    if property == Name and Puck.Name == "glovedpuck" then
        Puck.Anchored = true
        Whistle:Play()
    end
end)

-Arvid

0
yo ty KronxGoat 50 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You could use .Changed to detect the name change, for example:

script.Parent.Changed:Connect(function(ChangedProperty)
    if ChangedProperty = "Name" then -- Detect if the changed property is name
        if game.Workspace.Puck.Name == 'glovedpuck'  then
            script.Parent.Anchored = true   -- I would recommand u to put this script inside the part
            game.Workspace.GameSounds.Whistle:Play() 
        end
    end
end) -- Remember the ) !
0
that dosen't seem to work either KronxGoat 50 — 4y
0
Alright i changed a little bit, put this script in the Part (If there is any error in the output tell me) Nguyenlegiahung 1091 — 4y

Answer this question