So I’m making my Fire model, and I made some animations that I want to play when a player presses E (Originally it was I, but that was already binded), but this won’t work. My script:
local Player = game.Players.LocalPlayer
game.ReplicatedStorage.GUIs.ShowInteraction.OnClientEvent:Connect(function(purposeOfInteraction, partFired)
print("received event")
if purposeOfInteraction == "Fire" then
if (Player.Character.HumanoidRootPart.Position - partFired.Parent.FlamePart.Position).Magnitude <= 5 then
script.Parent.Visible = true
else
script.Parent.Visible = false
end
end
local UIS = game:GetService("UserInputService")
local IKey = Enum.KeyCode.E
local function IisDown()
return UIS:IsKeyDown(IKey)
end
local function IisDownCont(input, gameProcessedEvent)
print("Started IisDownCont function")
if IisDown() then
print("I is Down")
if purposeOfInteraction == "Fire" then
print("Purpose is Fire")
local animSit = Player.Character:WaitForChild("Humanoid"):LoadAnimation(script.Parent.Sit)
local animRubHands = Player.Character:WaitForChild("Humanoid"):LoadAnimation(script.Parent.RubHands)
local animStand = Player.Character:WaitForChild("Humanoid"):LoadAnimation(script.Parent.Stand)
if (Player.Character.HumanoidRootPart.Position - partFired.Parent.FlamePart.Position).Magnitude <= 3 then
print("Humanoid is in range")
local function sitAnim()
if not animSit.IsPlaying then
print("Sit animation is not playing, starting play.")
animSit:Play()
print("played, disconnecting")
sitAnim:Disconnect()
end
end
while true do
animRubHands:Play()
wait(3)
game.Players.LocalPlayer.Statistics.Warmth.Value = game.Players.LocalPlayer.Statistics.Warmth.Value + 10
end
local function standAnim()
if not animStand.IsPlaying then
print("Stand animation is not playing, starting play.")
animStand:Play()
print("played, disconnecting")
standAnim:Disconnect()
end
end
else
script.Parent.Visible = false
end
end
end
end
UIS.InputBegan:connect(IisDownCont)
end)
If there’s any confusion please let me know.