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

How would you go about changing Leaderstats Values in FE?

Asked by
Nikkulaos 229 Moderation Voter
6 years ago
Edited 6 years ago

I am working on a shop gui, and everything works except the stats dont actually change, and it shows it just for the player.

This is what i got so far:

The layout is like this: Button > Server Script, Local Script, and Remote Event (They are all inside the button)

Local Script:

local BuyEventOn = script.Parent:WaitForChild("BuyEvent")

local Player = game.Players.LocalPlayer
script.Parent.MouseButton1Down:Connect(function(click)

if Player:WaitForChild("leaderstats"):FindFirstChild("Money").Value > = script.Parent:WaitForChild("Cost").Value and Player:FindFirstChild(script.Parent.Name).Value == 0 then

BuyEventOn:FireServer()
print("1")
end
end)

Server Script:

local BuyEventOn = script.Parent:WaitForChild("BuyEvent")

local function BuyEvent1(Player)
print("2")

Player:WaitForChild("leaderstats"):FindFirstChild("Money").Value = Player:WaitForChild("leaderstats"):FindFirstChild("Money").Value - script.Parent:WaitForChild("Cost").Value

Player:FindFirstChild(script.Parent.Name).Value = 1
script.Parent.BackgroundColor3 = Color3.new(0, 255, 0)
end
BuyEventOn.OnServerEvent:Connect(BuyEvent1)

But what im wondering is how i would change the values to be compatible with fe. If you can help then please do! Thanks!

0
Change line 9 to script.Parent.BackgroundColor3 = Color3.fromRGB(0,255,0) saSlol2436 716 — 6y
0
Alright, ill go try that :p Also, there are no errors shown either Nikkulaos 229 — 6y
0
Sadly, the furthest it goes before breaking is print("1") on line 09. Everything else in the server script doesnt activate at all :( Nikkulaos 229 — 6y
0
Try sending the cost from the local script to the server script as a word, such as Player:WaitForChild("leaderstats"):FindFirstChild("Money").Value = Player:WaitForChild("leaderstats"):FindFirstChild("Money").Value - cost Kulh 125 — 6y
View all comments (2 more)
0
But the thing is that i think it might not work, because the print("2") part doesnt even get printed, and its below that cost part :( Is it possible that maybe the event is broken? Idk, lol Nikkulaos 229 — 6y
0
Server scripts don't run in many of the places that LocalScripts do. Ideally you have a single "Buy" server script that handles all the buy requests. Consider checking out the Guides tab at the top of Scripting Helpers -- it talks about RemoteEvents, server/client relationship, etc. chess123mate 5873 — 6y

Answer this question