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

Can I instance a mesh into my game?

Asked by 5 years ago
Edited 5 years ago

Hi, I am trying to make my script summon a part with a mesh in it. But when I do summon the part, it becomes a mesh but still looks like a part and not a thunderbolt (what the mesh is supposed to look like) how do I fix this?

Here is my script:

local player = game.Players.LocalPlayer
local character = player.CharacterAdded:Wait() 
local humanoid = character.Humanoid
local torso = character.UpperTorso
local mouse = player:GetMouse()
local thunderbolt = game.Workspace.Thunderbolt


local target



local God = player.PlayerGui.ChooseCharacter.God
--BREAKLINE--

local function onKeyPress(actionName, userInputState, inputObject)
    target = mouse.Target
    if userInputState == Enum.UserInputState.Begin then
        if God.Value == "Zeus" then  
            print("THUNDERBOLT!")
            local Thunder = Instance.new("Part")
            Thunder.Name = ("ThunderBolt")
            local mesh = Instance.new("SpecialMesh",ThunderBolt)

            Thunder.CFrame = CFrame.new(target.Position) 
            Thunder.Parent = workspace


        end
    end
end

game:GetService("ContextActionService"):BindAction(
    "keyPress", 
    onKeyPress, 
    false, 
    Enum.KeyCode.R,
    Enum.KeyCode.E
)

1 answer

Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
5 years ago
Edited 5 years ago

Get your mesh, get the mesh ID and your texture ID, and edit it using a property script. Also, you put ThunderBolt instead of Thunder.

local player = game.Players.LocalPlayer
local character = player.CharacterAdded:Wait() 
local humanoid = character.Humanoid
local torso = character.UpperTorso
local mouse = player:GetMouse()
local thunderbolt = game.Workspace.Thunderbolt


local target



local God = player.PlayerGui.ChooseCharacter.God
--BREAKLINE--

local function onKeyPress(actionName, userInputState, inputObject)
    target = mouse.Target
    if userInputState == Enum.UserInputState.Begin then
        if God.Value == "Zeus" then  
            print("THUNDERBOLT!")
            local Thunder = Instance.new("Part")
            Thunder.Name = ("ThunderBolt")
            local mesh = Instance.new("SpecialMesh",Thunder)
            mesh.MeshId = "MESH ID HERE"
            mesh.TextureId = "TEXTURE ID HERE"
            Thunder.CFrame = CFrame.new(target.Position) 
            Thunder.Parent = workspace


        end
    end
end

game:GetService("ContextActionService"):BindAction(
    "keyPress", 
    onKeyPress, 
    false, 
    Enum.KeyCode.R,
    Enum.KeyCode.E
)
0
ohhh ok thx! turbomegapower12345 48 — 5y
0
no problem! Mr_Unlucky 1085 — 5y
Ad

Answer this question