How to make it spawn helicopter

no spawn heli work

-- Define the phrase to trigger the action
local triggerPhrase = "my ROFLcopter goes soi soi soi"

-- Define the helicopter model to spawn
local helicopterModel = game.ServerStorage:FindFirstChild("HelicopterModel") -- Replace "YourHelicopterModel" with the actual name of your helicopter model

-- Function to handle player chat
local function onPlayerChat(player, message)
	-- Check if the message contains the trigger phrase
	if string.lower(message) == triggerPhrase then
		-- Spawn the helicopter near the player
		local character = player.Character
		if character then
			local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
			if humanoidRootPart and helicopterModel then
				local newPosition = humanoidRootPart.Position + Vector3.new(0, 5, 0) -- Adjust the position as needed
				local newHelicopter = helicopterModel:Clone()
				newHelicopter.Parent = game.Workspace
				newHelicopter:SetPrimaryPartCFrame(CFrame.new(newPosition))
			end
		end
	end
end

-- Connect the function to the player's chat event
game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		onPlayerChat(player, message)
	end)
end)

When using the string.lower() function on the chatted message, the triggerPhrase should also be all lowercase:

local triggerPhrase = "my roflcopter goes soi soi soi"

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.