Why is this code not executed?

local tool = script.Parent
local equipado = false
local uis = game:GetService("UserInputService")
local rs = game:GetService("RunService")
local Camera = game:GetService("Workspace").CurrentCamera
local zoom = false
local cameraPos = Vector3.new(2,0,8.5)
task.wait(0.05)
print("mamauevo")
rs.RenderStepped:Connect(function()
	if zoom  then
		print("siuuuu")
		Camera.CFrame = Camera.CFrame * CFrame.new(Vector3.new(0,0,-4.5))
          end
	end)
tool.Equipped:Connect(function()
	equipado = true
	print("equipo")
end)
tool.Unequipped:Connect(function()
	equipado = false
	if zoom then
		Camera.CFrame = Camera.CFrame * CFrame.new(Vector3.new(0,0,4.5))
		zoom = false
		print("desedfsdf")
	end
end)
uis.InputEnded:Connect(function(key)
	
	if key.UserInputType == Enum.UserInputType.MouseButton2 then
		if equipado then
			print("termindasd")
			zoom = false
			
		end
	end
end)
uis.InputBegan:Connect(function(key)
	if key.UserInputType == Enum.UserInputType.MouseButton2 then
		if equipado then
			zoom = true
			print("empezo")
		end
	end
	end)
	

the code is inside a tool which is in a folder in ServerStorage. when the player buys the tool it sends a remote event to the server via a local script. and then the server script clones the tool into the player’s backpack, there are other local and server scripts inside the tool that do run but that seems to be the only one that doesn’t run

1 Like

please help me this is very necessary for me today

1 Like

I’m not an expert with having more Functions, but the problem might be that because there’s one Function, it doesn’t run the others, try using task.spawn() or coroutines, that might work

2 Likes

is this in a local script in the tool and does it does it print at all ?

1 Like

How does Task.Spawn work? I don’t know what it is for and also I don’t know where I should put it… at the beginning of the script?

1 Like

It doesn’t print anything at all and I really don’t know why that happens

1 Like

Well, I don’t have any idea of how it works, but there’s other people that can tell you, maybe @GGYESPROLOL can

1 Like

is it in a local Script? and is that script in the tool

2 Likes

yes, it is in a local script and inside the tool

1 Like

i just looked at the code the code doesnt appear to be the problem but just to make sure try printing above the variables. and if that doesnt work send a picture of your explorer tab and your properties tab while having the script selected

1 Like

when the tool is in Starter Pack the script works without problems but when it is in Server Storage it gives problems after cloning itself inside the player’s backpack

1 Like

try putting it in rep storage its probably because serverscriptservice voids local and module scripts

if you clone it from rep Storage it will print

1 Like

Your setting the value of tool, to a folder in server storage, add a print statement before and after your first variable and see which one if either prints. Keep in mind items in ServerStorage aren’t immediately available to the client you must use a local script to clone it into the players backpack or descendants.

1 Like