Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to CORRECTLY pass variables in a Normal Script?

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

✓ Accepted answer

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)

2 comments

0

You are the best

0

No Your The Best For Accepting My Answer

This discussion is preserved as it was. New answers, comments, and votes are closed.