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

how do i make it so it doesn't spam my output with "GetPlayerFromCharacter" error stuff?

everytime this hits a wall, it will keep spamming the message in the title. how do i make it so it does not show all these errors? (like can i turn it off or something)

base=script.Parent
tag=base.OwnerTag
event = game:GetService("ReplicatedStorage")["KnifeDataTransferEvent"]

base.Touched:Connect(function(part)
	if part:IsDescendantOf(tag.Value.Character)==false then
		local enemy=part.Parent or game:GetService("Players"):GetPlayerFromCharacter(part:FindFirstAncestorWhichIsA("Model"))
		if enemy==true then
			event:FireClient(tag.Value,"Damage",base,enemy,nil)
		end
		wait(5)
		base:Destroy()
	end
end)

1 answer

✓ Accepted answer

While you cant disable the output directly you can use pcall and then if you want to debug it you can just print the error pcall gives you

base=script.Parent
tag=base.OwnerTag
event = game:service("ReplicatedStorage"):WaitForChild("KnifeDataTransferEvent")

base.Touched:Connect(function(part)
local s,e=pcall(function()
    if part:IsDescendantOf(tag.Value.Character)==false then
        local enemy=part.Parent or game:service("Players"):GetPlayerFromCharacter(part:FindFirstAncestorWhichIsA("Model"))
        if enemy==true then
            event:FireClient(tag.Value,"Damage",base,enemy,nil)
        end
        wait(5)
        base:Destroy()
    end
end)
if((not(s)and(e))or(e))then
--print(e) -- you can uncomment this later if you want to debug :P
end
end)

1 comment

0

youre a legend dude

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