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

How to CORRECTLY pass variables in a Normal Script?

Asked by 2 years ago

Trying to send variables from a Local Script to a normal Script. I coded it to print the variables after being sent (to Script) but I keep getting "nil". I've tried searching it up on Google but no success. (New to scripting so please forgive me if there are any idiotic errors)

Local Script:

local MorseCodePassing = game.ReplicatedStorage:WaitForChild("MorseCodePassing")
local name = "A"
local morsetext = ".-"
script.Parent.MouseButton1Click:Connect(function(name, morsetext)

    function Button(name, morsetext)
        if game.StarterGui.LettersMenu.Frame.Visible == false then
            game.StarterGui.LettersMenu.Frame.Visible = true
        end
        MorseCodePassing:FireServer(name, morsetext)
    end
end)

Normal Script:

local MorseCodePassing = game.ReplicatedStorage:WaitForChild("MorseCodePassing")

MorseCodePassing.OnServerEvent:Connect(name, morsetext)
print(name)
print(morsetext)

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

I Saw Alot Of Mistakes But As Your A New Scripter Here You Go

Script

local MorseCodePassing = game.ReplicatedStorage:WaitForChild("MorseCodePassing") -- Normal Script

MorseCodePassing.OnServerEvent:Connect(function(plr,name, morsetext) -- Mistake Is That You Didnt Added The Plr At First
    print(name)
    print(morsetext)
end)

Local Script

local MorseCodePassing = game.ReplicatedStorage:WaitForChild("MorseCodePassing") -- Local Script In A TextButton Or Anything You Want
local name = "A"
local morsetext = ".-"
local Button = script.Parent -- Directory To text Button
Button.MouseButton1Click:Connect(function()
    MorseCodePassing:FireServer(name, morsetext)
end)
0
You are the best Mafincho 43 — 2y
0
No Your The Best For Accepting My Answer kidsteve923 139 — 2y
Ad

Answer this question