I am working on a game, where players are climbing moving staircase and can cast spells (enchant) sections of it. One of the spells changes section into 1970's disco floor, and is supposed to freeze character and play a dance animation for 5 seconds. While I was able to freeze character, once a player tries to move or jump (which they usually do) the animation stops...
Since Create Stairs script is quite large I am posting just relevant section of it. (section fires when character touches the stairs's detection plate)
--make player dance
if stairBase.StairsType.Value == "disco" and not playersWhoDanced[player] and spell ~= "destroy" then
print (player, " entered")
playersWhoDanced[player] = true
local dance = PlayerStatManager:letsDance(player)
--wait(1) -- let them climb a bit :)
local memory = character.Humanoid.WalkSpeed
character.Humanoid.WalkSpeed = 0
wait(1)
dance:Play()
wait(5)
dance:Stop()
character.Humanoid.WalkSpeed = memory
spawn(function()
wait(2) -- i want players to dance at least twice
playersWhoDanced[player] = false
end)
end
Relevant fragment of PlayerStatManager script:
-- Setup table that we will return to scripts that require the ModuleScript.
local PlayerStatManager = {}
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=507771019" -- dance animation
local danceAnimation ={}
function PlayerStatManager:letsDance(player)
return danceAnimation[player]
end
local function setupPlayerData(player)
local character = player.character or player.CharacterAdded:wait()
local humanoid = character:WaitForChild("Humanoid")
wait(3) -- lame I know, but i get strange errors otherwise
danceAnimation[player] = humanoid:LoadAnimation(animation)
end
-- Bind setupPlayerData to PlayerAdded to call it when player joins.
game.Players.PlayerAdded:connect(setupPlayerData)
-- Return the PlayerStatManager table to external scripts can access it.
return PlayerStatManager
Early Alpha can be accessed here. Just jump on the yellow beacon to cast disco spell.

1 comment
Thank you kind sir, I will check this out now. Edit: It works, thank you. I did have used JumpPower before, I just did not thought about it for some reason... Maybe because it is 2am in UK right now, so I guess that's enough for today. Much appreciated.