Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is this script only performing properly on Studio, yet poorly on Client?

I'm making a fighting game where there are heroes that freely fight against each other. You can then get credits per kill and buy stronger heroes.

I'm trying to make it whenever you press the Deploy button (Which teleports the player into the battlefield [Something I haven't scripted yet] changes the character's appearance to the hero and gives them the weapon [Which temporarily is a sword] Including giving them the stats they need.)

The script works in studio, as it does change the character's appearance, the weapons they need, and the stats.

However, it doesn't work in Client. The only thing that works in Client is to make the GUIs not visible, and gives them the weapon. Everything else just fails.

To make matters worse for me, I have a loop script that it detects whenever a player's health is at 0, then they wait 5 seconds until they respawn, and that's when the DeployGUI shows out. In Client, it just makes the GUI pop out of nowhere, so whenever I still have full health in the middle of the battlefield, It just comes out.

May someone help me with the problem I am having? Also, I would like to know why it only works in Studio, but not on client.

Here is my script:

button.MouseButton1Down:connect(function()
	if currentloadout.CharacterId.Value == 1 then
		local hero = herostorage:FindFirstChild("Hero")
		hero:FindFirstChild("Body Colors"):clone().Parent = player.Character
		hero:FindFirstChild("NerdGlasses"):clone().Parent = player.Character
		hero:FindFirstChild("PurpleAntlers"):clone().Parent = player.Character
		hero:FindFirstChild("BeautifulBlackHair"):clone().Parent = player.Character
		player.Character:FindFirstChild("Head"):FindFirstChild("face").Texture = ("http://www.roblox.com/asset/?id=14020216")
		local humanoid = player.Character:FindFirstChild("Humanoid")
		humanoid.MaxHealth = 150
		humanoid.Health = 150
		humanoid.WalkSpeed = 20
		heroweapons:FindFirstChild("Hero"):FindFirstChild("Sword"):clone().Parent = player.Backpack
		hud:FindFirstChild("Deploy").Visible = false
		hud:FindFirstChild("LoadoutHud").Visible = false
		hud:FindFirstChild("Backgrounder").Visible = false
	end
end)

while true do
	wait()
	local humanoid = player.Character:FindFirstChild("Humanoid")
	if humanoid.Health == 0 then
		wait(5)
		hud:FindFirstChild("Deploy").Visible = true
		hud:FindFirstChild("LoadoutHud").Visible = true
		hud:FindFirstChild("Backgrounder").Visible = true
	end
end

If you need more of the script or the full script, just let me know.

1 answer

✓ Accepted answer

:clone() is not an instance. Instead, use :Clone()

1 comment

0

I COMPLETELY forgot about the differences between :clone() and :Clone(). Thanks for noticing!

This discussion is preserved as it was. New answers, comments, and votes are closed.