Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I spawn a model when the player chats?

So this script is suppose to spawn In one of my models when the player says something, but It's not working and I get no errors. It's in a local script.

local player = game.Players.LocalPlayer
local hum = player.Character:WaitForChild("Humanoid")
local pentagram = script.Parent
local spell = "Hello"


     player.Chatted:connect(function(message)
            if string.lower(message) == string.lower(spell) then
			wait(5)
		local crystal =	game:GetService("InsertService"):LoadAsset(278749111)
			crystal.Parent = game.Workspace
            crystal.Position = pentagram.Position --[[+ Vector3.new(0,5,0)]]--
			crystal.Transparency = 1
			wait(0.1)
			crystal.Transparency = 0.9
			wait(0.1)
			crystal.Transparency = 0.8
			wait(0.1)
			crystal.Transparency = 0.7
			wait(0.1)
			crystal.Transparency = 0.6
			wait(0.1)
			crystal.Transparency = 0.5
			wait(0.1)
			crystal.Transparency = 0.4
			wait(0.1)
			crystal.Transparency = 0.3
			wait(0.1)
			crystal.Transparency = 0.2
			wait(0.1)
			crystal.Transparency = 0.1
			wait(0.1)
			crystal.Transparency = 0 
     end
 end)


1 answer

Position is not a valid property of model and you will also want to wait until the character is loaded then declare it. e.g -

local player = game.Players.LocalPlayer
repeat wait() until player.Character -- repeats wait() until it can find player.Character
local char = player.Character

You are also not using the player's character or humanoid at all in this script so there really is no point in defining it.

To move the model you will have to do

Model:MoveTo(Vector3.new(0,6,0))

Something like that.

2 comments

0

I am using character I just deleted the code for testing purposes.

0

Still doesn't work.

This discussion is preserved as it was. New answers, comments, and votes are closed.