So, i was Actually Working on Placer Tool That Allows us to Spawn any Objects if we want!
I’m Modeling an Machine Called “Placer Changer” that Changes the Placer Tool. i Programmed it, and i Tested Out, But For Some Reason, It did not detect the Model because Script Thinks nothing was found on the folder, but it has Model in this Folder.
I Got Very Confused why Script not Detecting the Model on the Folder.
Here’s the Video For Example:
And Also Here’s the Script:
local Placer = game.ReplicatedStorage:WaitForChild("Placer")
local Storage = game.ReplicatedStorage.PlacerStorage
script.Parent.Frame.TextButton.MouseButton1Click:Connect(function()
if Storage:FindFirstChild(script.Parent.Frame.NameLabel.TextBox.Text) ~= nil then
script.Parent.Enabled = false
script.Parent.Parent["TurnOn/Off"]:Play()
script.Parent.Parent.Change:Play()
Placer.Selected.Value = Storage:FindFirstChild(script.Parent.Frame.NameLabel.TextBox.Text)
Placer.Delay.Value = script.Parent.Frame.DelayLabel.TextBox.Text
task.wait(0.5)
Placer.Parent = game.Workspace
Placer:PivotTo(script.Parent.Parent.Parent.Exit.Hole.CFrame)
else
script.Parent.Parent.Error:Play()
end
end)
i Tested Your Solution But I Got a Warning, “Infinite yield possible on 'ReplicatedStorage.PlacerStorage:WaitForChild(”“)'”. Can You Please Fix that Up?
Also could you test this inside the MouseButton1Click connection:
local Name = script.Parent.Frame.NameLabel.TextBox.Text
local Model = Storage:FindFirstChild(Name or "")
if Model then
print(Name .. " has been found")
...
Placer.Selected.Value = Model
...
else
print("Model not found: " .. Name)
...
end
Also let me know what gets printed when the model is not found.
Side-note, replace the ... with what you had previously in your script.
local Name = script.Parent.Frame.NameLabel.TextBox.Text
local Model = Storage:FindFirstChild(Name or "")
if Model then
print(Model, " has been found")
script.Parent.Enabled = false
script.Parent.Parent["TurnOn/Off"]:Play()
script.Parent.Parent.Change:Play()
Placer.Selected.Value = Model
Placer.Delay.Value = script.Parent.Frame.DelayLabel.TextBox.Text
task.wait(0.5)
Placer.Parent = game.Workspace
Placer:PivotTo(script.Parent.Parent.Parent.Exit.Hole.CFrame)
else
print("Model not found: " .. Name)
script.Parent.Parent.Error:Play()
end
Alright so the issue has to do with the script not being able to read the TextBox. This has to do with the script being server-sided, instead the script should be client-sided and then fire a RemoteEvent to the server with the name of the model. So basically you move the current connection of the server into a connection of a RemoteEvent being fired then you get a client to fire the RemoteEvent on MouseClick.