:Clone() not working?

the killed gui wont clone and i dont know why?

local declinevent = game.ReplicatedStorage.Quest:WaitForChild("Decline")
local rewardevent = game.ReplicatedStorage.Quest:WaitForChild("Reward")

acceptevent.OnServerEvent:Connect(function(player)
	print("Recieved")
	if player.PlayerGui:FindFirstChild("Quest") then
		player.PlayerGui.Quest:Destroy()
		local killedgui = script:WaitForChild("Killed"):Clone()
		killedgui.Parent = player.PlayerGui
		print("destroyed gui")
		
		local banditskilled = Instance.new("IntValue")
		banditskilled.Name = "killedbandits"
		banditskilled.Value = 0
		banditskilled.Parent = player
		
		local maxbandit = Instance.new("IntValue")
		maxbandit.Name = "maxbandits"
		maxbandit.Value = 5
		maxbandit.Parent = player
		
		
	end
end)

declinevent.OnServerEvent:Connect(function(player)
	print("Recieved")
	if player.PlayerGui:FindFirstChild("Quest") then
		player.PlayerGui.Quest:Destroy()
		print("destroyed gui")
	end
end)


rewardevent.OnServerEvent:Connect(function(player)
	player.Data.Cash.Value = player.Data.Cash.Value + 500
	player.PlayerGui.Killed:Destroy()
	player.killedbandits:Destroy()
	player.maxbandits:Destroy()
end)

Are there any errors in your output?

None at all i didnt have any i dont whats wrong.

Are you sure the event is getting fired. You claimed that there is nothing in the output but since you printed stuff there should be. Can you show us the script firing the remote event

i meant error wise the blocks of code with printed are getting printed just fine

Have you made sure the “killed” GUI is a child of the script? Here’s an example
image

I tested a simplified version of your script and it worked for me. Do note I kept your code original without reformatting it as I personally would of liked it. Cloning works so the issue is either 1) event not firing or 2) another error. Try to remove the :WaitForChild(“Killed”) to see if you get anything in the output that could be useful.

Bindable.Event:Connect(function(player)
	print("fired ",player.name)
	local killedgui = script:WaitForChild("Killed"):Clone()
	killedgui.Parent = player.PlayerGui
end)
1 Like

Are we sure the Quest is in there and there is something called Killed within the script as well.

1 Like

killed is in the script i will do the other things you said thank you for the tips

yep, both things are in there.

i found out the problem i accidently switched the accept local script with the decline local script