✓ Accepted answer
You could create an object value and give it the value of the model, then put the object value in the local script. The local script can then reference the model using the object value inside of it:
local model = script.value.Value
Example:
Script in ClickDetector
script.Parent.MouseClick:connect(function(player)
if not player.Backpack:FindFirstChild("InsertScript") then
local clone = game.ServerStorage:FindFirstChild("InsertScript"):Clone()
local m = Instance.new("ObjectValue",clone)
m.Name = "ModelValue"
m.Value = script.Parent.Parent.Parent
clone.Parent = player.Backpack
end
end)
Local Script
local model = script:FindFirstChild("ModelValue").Value
local player = game.Players.LocalPlayer
local character = player.Character
wait(5)
character:FindFirstChild("Torso").CFrame = model.Part.CFrame
script:Destroy()
I tested the script: Works fine. I put two models under the same name with the script in each of them, and the player was teleported to the part I clicked.
1 comment
could we see the script?