Changing Mesh textures on mobile devices is displayed with a bug that the Part itself becomes visible for a couple of seconds without Mesh, on PC devices everything is fine.
Adding ContentProvider didn’t helped
PC:
Mobile:
Local script:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local ContentProvider = game:GetService("ContentProvider")
local remotes = script.Parent:WaitForChild("Remotes")
local M1Event = remotes:WaitForChild("M1")
local M1DamageEvent = remotes:WaitForChild("M1Damage")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local states = player:WaitForChild("States")
local stunnedState = states:WaitForChild("Stunned")
local m1state = states:WaitForChild("M1")
local skillstate = states:WaitForChild("Skill")
local attackButton = player.PlayerGui.ScreenGui.M1
local animationsFolder = ReplicatedStorage:WaitForChild("Animations")
local staffAttackAnim = animationsFolder:WaitForChild("Weapons"):WaitForChild("Staff"):WaitForChild("StaffAttack1")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(staffAttackAnim)
local cooldown = 1.5
local lastAttackTime = 0
local SlashTextures = {
'rbxassetid://8821193347',
'rbxassetid://8821230983',
'rbxassetid://8821246947',
'rbxassetid://8821254467',
'rbxassetid://8821272181',
'rbxassetid://8821280832',
'rbxassetid://8821300395',
'rbxassetid://8821311218',
'rbxassetid://8896641723',
}
ContentProvider:PreloadAsync(SlashTextures)
local function slash(character)
local slash = ReplicatedStorage.VFX.Weapons.Staff.Slash:Clone()
local hrp = character:WaitForChild("HumanoidRootPart")
slash.Parent = workspace
slash.Anchored = true
local rotationValue = Instance.new("NumberValue")
rotationValue.Value = 0
local tweenInfo = TweenInfo.new(0.8)
local tween = TweenService:Create(
rotationValue,
tweenInfo,
{Value = -390}
)
local updateConnection
updateConnection = game:GetService("RunService").RenderStepped:Connect(function()
if slash and slash.Parent and hrp and hrp.Parent then
slash.CFrame = hrp.CFrame * CFrame.Angles(0, math.rad(rotationValue.Value), 0)
else
if updateConnection then
updateConnection:Disconnect()
end
end
end)
tween:Play()
task.spawn(function()
local numTextures = #SlashTextures
local timePerTexture = tweenInfo.Time / numTextures
for i = 1, numTextures do
if not slash or not slash.Parent then break end
slash.Mesh.TextureId = SlashTextures[i]
task.wait(timePerTexture)
end
end)
tween.Completed:Connect(function()
if updateConnection then
updateConnection:Disconnect()
end
rotationValue:Destroy()
if slash and slash.Parent then
slash:Destroy()
end
end)
end
local function performAttack()
local currentTime = tick()
if stunnedState.Value or skillstate.Value or m1state.Value then
return
end
if currentTime - lastAttackTime >= cooldown then
if not animationTrack.IsPlaying then
animationTrack:Play()
slash(player.Character)
M1Event:FireServer()
lastAttackTime = currentTime
end
end
end
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
performAttack()
end
end)
attackButton.Activated:Connect(function()
performAttack()
end)
animationTrack:GetMarkerReachedSignal("hit1"):Connect(function()
M1DamageEvent:FireServer("startDamage", "hit1")
end)
animationTrack.Stopped:Connect(function()
M1DamageEvent:FireServer("endDamage")
end)
Also i tried to put a part with a specialMesh inside the workspace with script that changes its texture every 1 second, it was slow so i thought it will load faster, well, it didn’t, so the texture change time doesn’t change anything
local part = script.Parent
local SlashTextures = {
'rbxassetid://8821193347',
'rbxassetid://8821230983',
'rbxassetid://8821246947',
'rbxassetid://8821254467',
'rbxassetid://8821272181',
'rbxassetid://8821280832',
'rbxassetid://8821300395',
'rbxassetid://8821311218',
'rbxassetid://8896641723',
}
while true do
local numTextures = #SlashTextures
local timePerTexture = 1
for i = 1, numTextures do
part.Mesh.TextureId = SlashTextures[i]
task.wait(timePerTexture)
end
end