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

How to enable a script by touching a brick?

Asked by 6 years ago

For the past few days, I've been trying to make an animation play when I touch a jump boost brick. I've tried to do it with different scripts but I realized I can have the script that plays the animation when I press space disabled, then a script in the brick enables it when I touch it.

This is the script I've come up with:

local lolxbork = script.Parent

local function steppedOn(part)
    local parent = part.Parent
    if game.Players:GetPlayerFromCharacter(parent) then
        game.StarterPack.animation.Disabled=false
    end
end


lolxbork.Touched:connect(steppedOn)

When I collide with the brick, nothing happens, and I only get the jump boost from the brick right in front of it.

Then I remembered this site exists, so I'm asking what the error is.

Thanks!

1 answer

Log in to vote
0
Answered by 6 years ago

Starterpack clones the items into every player's backpack. It isn't where the physical item is stored, so by linking to starterpack you're not linking to the character's backpack. Instead of doing

game.StarterPack.animation.Disabled

on line 6,

you would do

game.Players:GetPlayerFromCharacter(parent).animation.Disabled

since the animation script that animates the player would be in their backpack.

Ad

Answer this question