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

A localscript in a tool doesnt know a local i made in serverscriptservice?

Asked by 4 years ago
Edited 4 years ago

hi everyone, so i made this click-detector, but it wont add points. This script is in a normal script in serverscriptservice:

game.Players.PlayerAdded:Connect(function(player)
    print("LeaderStats")
    local stats = Instance.new('IntValue', player)
    stats.Name = 'stats'

    print("Stats")
    local IQ = Instance.new("IntValue", stats)
    IQ.Name = "IQ"
    IQ.Value = 0
end)

This is a script inside of a tool in the starterpack:

script.Parent.Parent.Equipped:Connect(function(mouse)
    mouse.Button1Down:Connect(function()
        print ("clicked")
        IQ.Value = IQ.Value + 1
    end)
end)

In the output it says that IQ is not defined... how do i allow the localscript to use a local from the serverscriptservice?

1 answer

Log in to vote
0
Answered by 4 years ago

Read up on more lua. The way I’ll do it is create an IntValue that represents the leaderboard stat and that value has to be somewhere parented under player so you can get it. Also since it’s FE you cannot change anything within a localscript so make a RemoteFunction to do that

0
its litterally a intvalue in the player already wth sinbadxfan05 3 — 4y
Ad

Answer this question