Hi there!
I wanted to make an admin panel for my game, and wanted to make it so that when i click a button, it teleports a dummy out of ServerStorage to a few studs in front of the player.
However, due to my limited scripting ability, i did not really know how to start. I tried to make a script, but could not think of how to do it.
As far as i am concerned, there is not much on the developer hub, nor is there a youtube tutorial.
If anyone can help put me on the right track, then that would be amazing!
So this is fairly simple to do. First, we’ll need to set up an Remote Event and store that in ReplicatedStorage. Then, create a script in ServerScriptService and then input the following code:
local some_dummy = game.ServerStorage:WaitForChild("DUMMY!")
game.ReplicatedStorage:WaitForChild("RemoteEvent").OnServerEvent:Connect(function(player)
local new_dummy = some_dummy:Clone()
new_dummy.Parent = game.Workspace
new_dummy:MakeJoints()
local pos = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5)
new_dummy:MoveTo(pos.p)
end)
Then we’ll set up a script in the button in the client’s UI, and input the following code:
local db
local event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
script.Parent.MouseButton1Down:Connect(function()
if not db then
db = true
event:FireServer()
wait(3)
db = false
end
end)
This should roughly be what you’re looking for. I may have forgotten the correct coordinates for spawning an object in front of another, so you might have to tweak the CFrame coordinate I’ve put in. I thought a Z of 5 was correct, if it isn’t it might have to be negative. Anywho, hope this helps!
So, I’d use a TextButton for the admin pannel and I’d use a RemoteEvent.
They’ll be 2 scripts, a Script in ServerScriptService and a LocalScript inside the TextButton.
Also make sure the Dummy has a PrimaryPart set.
On MouseButton1Click of that Button Connect and fire the Remote Event (:FireServer())
Connect OnServerEvent of that RemoteEvent in the Script, remember that the first parameter is the player who fired - you can use this for referencing the player.
Now call :Clone() upon the dummy, parent it to workspace and call :SetPrimaryPartCFrame() upon the model - give it a CFrame of probably: