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

Transfering data to a other script not working?

Asked by 6 years ago

Hello I made a script for a shop with a PurchaseHandler and the data transfer over the remotefunction isn't working it says then: "PlayerScripts are not a valid Member of Player" but my name is LazyTfftALT so it isn't working or on Cash it says then Cash not the transfered Value how do I fix it.

The Progressor:

script.Parent.MouseButton1Click:Connect(function(player)
    local Coinst = 1000
    local Cash = 1000

    local player = game.Players.LocalPlayer
    if player.PlayerScripts.Coins.Value >= Coinst then
        script.Parent.Text = "Progressing"

        print("invoked")
        game.Workspace.PurchaseHandler.DataHandler:InvokeServer(player,Coinst,Cash)
        print("e")
        wait(1)
        script.Parent.Text = "Bought!"
        wait(2)
        script.Parent.Text = "1k Cash - 1000 Coins"
    else
        script.Parent.Text = "You don't have enough Coins!"
        wait(3)
        script.Parent.Text = "1k Cash - 1000 Coins"
    end
end)

And here the Purchase Handler:

script.DataHandler.OnServerInvoke = function(player,Coinst,Cash)
    local plr = player:WaitForChild("Coins")
    plr.Value = plr.Value -Coinst
    local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
            if cashmoney then
                cashmoney.Value = cashmoney.Value + Cash
            end
end

1 answer

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

You cannot achieve PlayerScripts from the Server with FilteringEnabled... I had the same problem...

Try putting the Coins Value into the ReplicatedStorage

Ad

Answer this question