I have a textbox and a button. I want it so that when you click the button, whatever you typed into the textbox spawns on the map near you. So far I’ve been able to resolve tons of bugs in the last few hours, and I believe this could be my last thread for now.
I’ve been able to make the entire script work, and each of the requested models does spawn, however, just once.
-- button local script, fires the event
local RE = game.ReplicatedStorage.RemoteEvent
local button = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui").Frame.ImageButton
local textBox = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui").Frame.TextBox
button.MouseButton1Click:Connect(function()
RE:FireServer(string.lower(textBox.Text))
end)
-- serverscriptservice server script, processes the event
...
RE.OnServerEvent:Connect(function(plr, textInput)
if repstorage.Stuff:FindFirstChild(textInput) then
local model = repstorage.Stuff:FindFirstChild(textInput)
local modelclone = model:Clone()
modelclone.Parent = workspace
modelclone:SetPrimaryPartCFrame(humroot.CFrame)
modelclone:TranslateBy(Vector3.new(5, 0, 5))
else
...
end
end)
I’d like the models to be cloned each time I ask for them. Any ideas on how could I make that happen?
Any errors?
Try doing some print debugging, I would add some random print statements and see if anything out of the ordinary happens so that I can pinpoint the problem
like in between here
print something to see if it will run when you type the item for a second time.
you can also try printing the model after
The script detects that a known string is used and clones the part, however gets stuck when the parameters are specified because this line is written incorrectly.
-- serverscriptservice server script, processes the event
RE.OnServerEvent:Connect(function(plr, textInput)
if repstorage.Stuff:FindFirstChild(textInput) then
local model = repstorage.Stuff:FindFirstChild(textInput)
local modelclone = model:Clone()
modelclone.Parent = workspace
modelclone:PivotTo(humroot.CFrame)
modelclone:TranslateBy(Vector3.new(5, 0, 5))
else
...
end
end)
Thank you! This will save me a lot of work. The basics of my game are now done and I don’t have to worry about making dozens of threads on the Devforum anymore.