Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to enable a script by touching a brick?

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

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.