This is my second time having to ask this question due to people answering it incorrectly before, but I'm trying to clone objects from ReplicatedStorage, into the player's camera. It works perfectly fine in Studio with no problems, but in Player, it doesn't even send an output, no errors involved.

If anyone sees anything wrong with the script (especially line 12) then feel free to answer it. [Filtering Enabled is on]

local buttonPressed = false
 
game.Workspace.Stage2.SkeletonRun.Touched:Connect(function(hit)
	
if not buttonPressed then
 
buttonPressed = true

local obj = game.ReplicatedStorage:WaitForChild("Objects")
local plr = game.Players.LocalPlayer
if(game.Players:GetPlayerFromCharacter(hit.Parent)==plr)then
obj:Clone().Parent = workspace.Camera
hit.Parent.Humanoid.WalkSpeed = 0
hit.Parent.Humanoid.JumpPower = 0
plr.CameraMinZoomDistance = 0
plr.CameraMaxZoomDistance = 0
wait(1)
hit.Parent.Humanoid.WalkSpeed = 65 --stop changing the speeds, there are at a certain speed to balance the game
wait(1)
 
buttonPressed = false
end
end
end)

2 comments

0

I wasn't cloning anything but something worked fine in studio but not in player once for me, then I just moved my code from a script to a localscript and it worked fine.

0

LocalScripts don't work for a function