I put a script inside of a textbutton and its suppose to make the train move and also add 1 to the players stats. But so far it only moves the train and doesn’t add anything to the player’s stats. This is the script I’ve been working on so far, please let me know if you encounter any errors. I tried using remote events but I have no idea how to use it. I tried reading this about Remote Events but I still have no idea how to use it.
Here is the script:
local Train = game.Workspace.Train
function move()
for v = 0,1,.05 do
Train:SetPrimaryPartCFrame(Train:GetPrimaryPartCFrame() * CFrame.new(0,0, -v))
wait()
end
while wait() do
Train:SetPrimaryPartCFrame(Train:GetPrimaryPartCFrame() * CFrame.new(0,0,0 + -1.9))
end
end
function Give()
game.Players.LocalPlayer.TimesRanOver.Value = game.Players.LocalPlayer.TimesRanOver.Value +1
end
script.Parent.MouseButton1Click:Connect(function(plr)
script.Parent:Destroy()
move()
Give()
end)
```S