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

[Fixed] How do i fix "Script that implemented this callback has been destroyed"? (Datastores)

Asked by
me_DS 0
4 years ago
Edited 4 years ago

So i am using datastores2 to get a value and set it as the contents of a button. This works, except when i click Stop (in playtest mode), it breaks roblox studio completely.

Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")

local DataStore2 = require(ServerScriptService.DataStore2)

function settext() 
    local pointsStore = DataStore2("points", script.Parent.Parent.Parent.Parent.Parent) -- This is what seems to be the issue, found that out by commenting the 2 lines below this and the error still apears...
    script.Parent.Text="Points: " .. pointsStore:Get(100)
        pointsStore:Increment(1)
end

script.Parent.MouseButton1Click:Connect(settext)

Images:

StarterGUI Structure: https://gyazo.com/bf78e96d18b06b445e16b8b0a7527403

Error:

  • https://gyazo.com/c1242750b3466fd77ef154c562e1c6f9

  • https://gyazo.com/f0e87826129fab50bfed4d5c6a7ebbca

EDIT: Seems like the latest Roblox Studio update fixed this :D

0
What is script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent ? You should never have this many .Parent's in a row. You should be using variables to shorten this programmerHere 371 — 4y
0
@programmerHere I was gonna change it eventually, but changing it to a variable has no impact on the situation. script.Parent.Parent.Parent.Parent.Parent is the same thing as for a localscript "game.Players.LocalPlayer" - i am not using a localscript, because if i was, i could not access datastores/datastores2 me_DS 0 — 4y

Answer this question