Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I spawn a model when the player chats?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

Log in to vote
0
Answered by
Ryzox 220 Moderation Voter
9 years ago

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.

0
I am using character I just deleted the code for testing purposes. 64batsalex 45 — 9y
0
Still doesn't work. 64batsalex 45 — 9y
Ad

Answer this question