So.. I'm making this game where you collect berries. There's a script that I've requested help with before on this website, that I recently updated to be compatible with new changes to the game, but just like last time, my output's being bombarded by error messages even though the script works as intended. However, having my output basically unreadable is definitely not wanted. Anyways, the script is supposed to activate a billboardGUI (dex) whenever a player hovers their mouse over a "berry", I've added this part that is the parent of "berry" that if hovered over, will disable the same GUI as previously enabled. But when I look at the bush (berry.Parent.Parent) that the berry is in, this error message pops up in the output: Berry is not a valid member of UnionOperation. (The bush is a union) Anyhow, here's the script, hope someone can help xD:
local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.Move:Connect (function() if mouse.Target then local target = mouse.Target if target and target.Parent then if target:FindFirstChild ("dex") then target.dex.Enabled = true if target.Transparency == 1 then target.dex.Enabled = false end elseif target:FindFirstChild ("DexOff") then target:FindFirstChild ("DexOff").Parent.Berry.dex.Enabled = false end end end end)
you should use a pcall
, they are used like this:
pcall(function() --<Code>-- end)
and let's say that you have a error
error("Random error")
and you want to avoid it, just put a pcall
pcall(function() error("Random error") end)
if you actually put that in a script (first the error and then the call with error) then you'll see that the one with call ignores the error and continues with the rest of the script
--This function holds in an error local success, errormessage = pcall(function() end)
Link - Third function