How would I fix a script that works in studio but not in game?

Hey devforum, again, theres a script I have that works in studio but doesnt work in game, even though I’m using the same script a ton,

script:

local dropper = script.Parent

local cashui = game.ReplicatedStorage.CashValueUI

while wait(5) do
	local drop = Instance.new("Part")
	local newcashui = cashui:Clone()
	
	newcashui.Parent = drop
	newcashui.TextLabel.Text = "$"..dropper.DropperPart.ValueSetter.Value
	
	drop.Name = "Drop"
	drop.Position = dropper.DropperPart.Position
	drop.Size = Vector3.new(1,1,1)
	drop.Color = Color3.new(0.290196, 0.227451, 0.0745098)
	drop.Material = Enum.Material.CorrodedMetal
	drop.Parent = workspace
	drop.Anchored = false
	

	local cashvalue = Instance.new("NumberValue")
	cashvalue.Value = dropper.DropperPart.ValueSetter.Value
	cashvalue.Name = "CashValue"
	cashvalue.Parent = drop
end

I dont think anything is wrong with the script, I think its more so studio, not sure, but if you could help that would be greatly appreciated.

Try using the IsStudio() function in RunService

How would I use it? And where would I use it

local RunService = game:GetService(“RunService”)

If RunService:IsStudio() == true then
—your code
end

I’m not totally sure if this will work and I can’t test it because I don’t have access to my laptop right now.

Ill try it out, and thanks for helping

Ok good luck! Let me know if it works!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.