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

How am I attempting to call an instance value?

Asked by 3 years ago
Edited 3 years ago

I'm gettting this error: "09:56:24.608 ServerScriptService.Remotes:13: attempt to call a Instance value - Server - Remotes:13"

I don't know how to fix this one (I am new so I have to learn a lot)

Code:

local replicatedStorage = game:GetService("ReplicatedStorage") local remoteData = game:GetService("ServerStorage"):WaitForChild("RemoteData")

local cooldown = 1

replicatedStorage.Remotes.Lift.OnServerEvent:Connect(function(player)

print("Fired")

if not remoteData:FindFirstChild(player.Name) then return "NoFolder" end


local debounce = remoteData(player.Name).Debounce  - - The Error Is in this line


print("Got past the Debounce variable")

if not debounce.Value then

    debounce.Value = true

    player.leaderstats.Strength.Value = player.leaderstats.Strength.Value + 25 * (player.leaderstats.Rebirths.Value + 1)

    wait(cooldown)

    debounce.Value = false

end

end)

1 answer

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

An instance is basically any Roblox object, and it looks like remoteData is a folder or something but I'm not really sure. You're calling remoteData like you would call a function, but remoteData is an instance and not a function, so it gives an error

I think you were trying to do this on line 6

local debounce = remoteData[player.Name].Debounce 

and made a typo, but if you don't know what this does, here is an explanation:

Roblox represents objects in the Explorer with tables, and "workspace.Folder.Part" is just a nicer way to write workspace["Folder"]["Part"] (and you can do this with any table if you use strings as keys:

local myTable = {
    ["hello"] = "world"
}
print(myTable.hello) --> "world"
print(myTable["hello"]) --> "world"

Getting a value in a table using the nicer syntax is more strict, so you couldn't do this

local debounce = remoteData.player.Name.Debounce 

so you need to do this

local debounce = remoteData[player.Name].Debounce 
0
Yes, Thank you! But what is the difference between (player.Name) and [player.Name]? Stef252 4 — 3y
0
You call a function using parentheses, and function arguments go inside the parentheses. You get a value in a table using brackets, with the table key (where the value is stored in the table) going inside the brackets. Calling a function using someFunction[] would cause an error, and getting a value from a table using someTable(key) would cause an error  OfficerBrah 494 — 3y
0
which is basically what you did since Roblox represents objects as tables OfficerBrah 494 — 3y
0
Ah ok, thank you. Stef252 4 — 3y
View all comments (2 more)
0
I just started scripting, so I am trying to learn it all, but it is reamly hard xD. Stef252 4 — 3y
0
glad to help :) OfficerBrah 494 — 3y
Ad

Answer this question