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

How could I change this to ACTUALLY delete 'base'? (further explanation)

So I have a knife, and a (server) script that handles whatever knife is thrown (this script is placed inside the knife, defined as base) and every time It hits a wall that IS NOT either the player throwing the knife (defined as tag) or a wall.

Problem: It does not actually delete. Question: How do I fix this so it does delete itself?

Common Errors shown: GetPlayerFromCharacter is not a valid member of Model "__"

base=script.Parent
tag=base.OwnerTag
player=base.OwnerNString
event = game:GetService("ReplicatedStorage")["KnifeDataTransferEvent"]
enabled=true
base.Touched:Connect(function(part)
	if part:IsDescendantOf(tag.Value.Character)==false then
		if enabled==true then
			if part.Parent:FindFirstChildWhichIsA("Humanoid") or part.Parent:GetPlayerFromCharacter() then
				local enemy=part.Parent
				if (tag.Team~=enemy:GetPlayerFromCharacter().Team) or (tag.Team==nil and enemy:GetPlayerFromCharacter().Team==nil) (tag.Team==nil and enemy.Parent:GetPlayerFromCharacter().Team==nil) then
					event:FireClient(tag.value,"Damage",base,enemy,nil)
				else
					base:Destroy()
				end
				base:Destroy()	
			end
		end
	end
end)

1 answer

✓ Accepted answer

You're using :GetPlayerFromCharacter() wrong. Try doing

game.Players:GetPlayerFromCharacter(enemy)

1 comment

0

oh my god thank you so much this saved me so much time trying to fix it myself

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