Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
hmurban 16
6 years ago

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)
0
I answered your question. I hope it helps! User#21908 42 — 6y
0
If I helped you out please accept my answer! User#21908 42 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

0
thanks incapaz :D hmurban 16 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

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!

0
thanks ^^ hmurban 16 — 6y
0
I did understand that I just didn't explain it. I will edit my answer User#19524 175 — 6y

Answer this question