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

how do i make when i type for example "Boat" It spawn a boat?

Hello SH Community, i have a question im new, how do i make when i type for example "Boat" It spawn a boat?

I Need it for a game im working on. If you know how, please tell me. Im new at developing.

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(messageSent,PlayerGettingMessaged)
        --Check if message is boat, then clone a boat if it is.
    end)
end)

How do i continue??

1 comment

0

Please try and make an attempt at the code before asking here

2 answers

✓ Accepted answer
game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(messageSent,PlayerGettingMessaged)
        local message = string.lower(messageSent) --say if messageSent is "bOAT" or "BOAT" it's always read as "boat"
		if message = "boat" then --If the player said "boat"
			local boat --Assign the boat model here
			boat = boat:Clone()
			boat.Parent = workspace
			local mainPart = boat.PrimaryPart --Make sure you set a PrimaryPart property!
			mainPart.CFrame = player.Character["NAME A BODY PART HERE"].CFrame --Explanation below
		end
    end)
end)

It's pretty hard to explain CFrame, so I'll link you here for an in-deph explanation

4 comments

0

Thank you so much

0

Where do i put it?

0

put it in serverscriptservice

0

ok ty

You would use the chatted event. Here is what it looks like:

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(messageSent,PlayerGettingMessaged)
		--Check if message is boat, then clone a boat if it is.
	end)
end)

1 comment

0

How do i continue?

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