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

My elseif isn't working how I thought it would, help?

game.ReplicatedStorage.ModeEvents.NoModeEvent.OnServerEvent:Connect(function(plr, sentBool)
        local char = plr.Character.Torso
	if char.TynReleaseEffect then
		char.TynReleaseEffect:Remove()
	elseif
		char.TynRelease2Effect then
			char.TynRelease2Effect:Remove()
	elseif
		char.TynRelease3Effect then
			char.TynRelease3effect:Remove()
	end
end)

Is there anyway I can run have TynRelease2Effect without TynReleaseEffect?

2 comments

0

Any errors

0

"TynReleaseEffect is not a valid member of the Part"

1 answer

✓ Accepted answer

Hey there,

First off you should use :Destroy() rather than :Remove() (deprecated).

Second, if you want to see if something is a child of an instance, you should use :FindFirstChild()

In the end, your code should look like this...

game.ReplicatedStorage.ModeEvents.NoModeEvent.OnServerEvent:Connect(function(plr, sentBool)
    local char = plr.Character.Torso
    if char:FindFirstChild("TynReleaseEffect") then
        char.TynReleaseEffect:Destroy()
    elseif char:FindFirstChild("TynRelease2Effect") then
		char.TynRelease2Effect:Destroy()
    elseif char:FindFirstChild("TynRelease3Effect") then
    	char.TynRelease3effect:Destroy()
    end
end)

p.s. there is no Torso in R15 characters (only in R6 characters). You should put things in the HumanoidRootPart as it's present in R15 and R6 characters

If this didn't help or you run into future issues with your code, just reply to this answer with any questions.

If this helped, remember to accept and upvote the answer.

1 comment

0

Thank you so much! I use R6 btw.

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