I have been having a lot of trouble getting a variable in my local script to my server script from teleport data is there any way to do this?
The best way to do this is to use bindable events,
So say your workspace looked something like this
Workspace -Script1 -Script2 -BindableEvent
What we would want to do to transfer a variable from Script1 to Script2 which has a remove event,
In Script1 our code would look something like this
WaitForVariable = game.Workspace:WaitForChild("Script2") --Here we are waiting for Script2 to exist in the workspace. myVariable = 123 --Here we are defining the variable game.Workspace.Script2.BindableEvent.Fire(myVariable) --Here we are activating the event
In Script2 We would need to get that data that we just sent over,
function DataTransfer(Data) myVariable = Data end script.Event.Event:Connect(DataTransfer)
Now if we were to print myVariable it should print 123.
Or you can make Remote events
Examples:
Local Script:
workspace.ChildAdded:Connect(function(add) script.Parent.Remotes.Child.Added:FireServer(add) end)
Server Script:
script.Parent.Child.Added.OnServerEvent:Connect(function(add) if add then if add:IsA("Part") then add.Shape = "Ball" end end end)