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

can someone help me with fire server and remote function with a rebirth system?

Asked by 4 years ago
Edited 4 years ago

here's the normal script:

local replicatedStorage = game:GetService("ReplicatedStorage")
local starterRebirthAmount = 5000

local player = game.Players.LocalPlayer
local mainFrame = script.Parent:WaitForChild("MainFrame")
local rebirthMenu = mainFrame:WaitForChild("RebirthMenu")
local mainButton = script.Parent:WaitForChild("MainButton")
local rebirthButton = rebirthMenu:WaitForChild("RebirthButton")
local strengthToRebirth = rebirthMenu:WaitForChild("StrengthToRebirth")
local rebirths = player:WaitForChild("leaderstats").Rebirths


strengthToRebirth.Text = "You need at least "..math.floor((starterRebirthAmount + (rebirths.Value) * math.sqrt(50000000))).."strength to rebirth"

mainButton.MouseButton1Click:Connect(function()
    mainFrame.Visible = not mainFrame.Visible
end)


rebirthButton.MouseButton1Click:Connect(function()
    local result = replicatedStorage.Remotes.Rebirth:FireServer()

    if result == true then
        rebirthButton.Text = "Nice Job 8D"
        wait(5)
        rebirthButton.Text = "CLICK HERE TO REBIRTH"
    elseif result == "NotEnoughStrength" then
        rebirthButton.Text = "Sorry :'("
        wait(1)
        rebirthButton.Text = "CLICK HERE TO REBIRTH"

    end
end)

rebirths:GetPropertyChangedSignal("Value"):Connect(function()
    strengthToRebirth.Text = "You need at least "..math.floor((starterRebirthAmount + (rebirths.Value) * math.sqrt(50000000))).."strength to rebirth"
end)

idk if this will help, but here's the local server:

local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteData = game:GetService("ServerStorage"):WaitForChild("RemoteData")
local starterRebirthAmount = 5000
local rebirth = game:GetService("ReplicatedStorage").Remotes.Rebirth
local cooldown = 0.1

replicatedStorage.Remotes.Lift.OnServerEvent:Connect(function(player)

    if not remoteData:FindFirstChild(player.Name) then return "NoFolder" end

    local debounce = remoteData:WaitForChild(player.Name).Debounce

    if debounce.Value == false then

        debounce.Value = true

        player.leaderstats.Strength.Value = player.leaderstats.Strength.Value + 1 * (player.leaderstats.Rebirths.Value + 1)

        wait(cooldown)

        debounce.Value = false

    end
end)

rebirth.OnServerInvoke = function(player)
        if not remoteData:FindFirstChild(player.Name) then return "NoFolder" end

        local rebirths = player.leaderstats.Rebirths

        if player.leaderstats.Strength.Value >= (math.floor((starterRebirthAmount + (rebirths.Value) * math.sqrt(50000000)))) then

            rebirths.Value = rebirths.Value + 1

            player.leaderstats.Strength.Value = 0

            player:LoadCharacter()
            return true
    else return "NotEnoughStrength"
        end
end

here's the output:

23:27:13.810 - size simulator @ 22 Jul 2019 23:27 auto-recovery file was created
  23:30:00.667 - FireServer is not a valid member of RemoteFunction
23:30:00.669 - Stack Begin
23:30:00.670 - Script 'Players.Gueli844.PlayerGui.Main.LocalScript', Line 21
23:30:00.672 - Stack End
23:32:36.967 - Disconnect from 127.0.0.1|51832

will be glad to give any more info, thx :)

0
Should be :InvokeServer(), not :FireServer(). Line 21, I believe.  User#26971 0 — 4y
0
If that fixes the issue, put [Solved] in your title, so people know you no longer need help. User#26971 0 — 4y

Answer this question