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

attempt to index global "remove" (a function value)..how to fix this ?

they should remove an accessory called "acc" from the character but that error appeared in the output menu..so what to do ? (the remoteEvent called "remove" )

the localscript (inside a textbutton)

button = script.Parent
rbl = game:GetService("ReplicatedStorage")
remove = rbl.remove
button.MouseButton1Click:Connect(function() 
remove:FireServer()
end)

the server-sided script (serverscriptservice)

rblstorage = game:GetService("ReplicatedStorage")
remove = rblstorage.remove
 
remove.OnServerEvent:Connect(function(plr)
	local char = plr.Character
	local acc = char:FindFirstChild("acc")
	acc:Destroy()
	
end)

2 comments

0

I answered your question. I hope it helps!

0

If I helped you out please accept my answer!

2 answers

✓ Accepted answer

###This is because Instance:remove(). It is an old, deprecated method that existed before Instance:Destroy(). When you do this:

remove = rblstorage.remove

###You're really just storing the function in a variable. Remember that this:

rblstorage:remove()

###Is just syntax sugar for this:

rblstorage.remove(rblstorage) -- not syntax sugar 

remove = rblstorage.remove -- acceptable 
remove(rblstorage) -- acceptable

###Though anything can go as an argument. You'll have to name it something like "REMOVE" as "Remove" has the same effect.

1 comment

0

thanks incapaz :D

You need to name the child of ReplicatedStorage something else. The problem you are encountering is that remove is a deprecated function in Roblox Lua. You are using a function on accident. A very simple solution would be to change the name of what I think is your remote event. What @incapaz did not understand is that you are using :Destroy() and that remove is the name of your remote event. What you did not know was that remove was actually a roblox function. Just change the name to something else. Hope this helps and have a great day scripting!

2 comments

0

thanks ^^

0

I did understand that I just didn't explain it. I will edit my answer

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