So I have a swimming system. There are a ton of other scripts but I’m pretty sure this is the main one that’s important. So it’s meant to originally load a mesh but when I replaced the Mesh with a Model, same name, it completely breaks. So I’m wondering if anyone knows why:
--Services{
local replicatedStorage = game:GetService("ReplicatedStorage")
local tweenService = game:GetService("TweenService")
local soundService = game:GetService("SoundService")
local runService = game:GetService("RunService")
local debris = game:GetService("Debris")
--}
--Vars{
local assets = replicatedStorage:WaitForChild("Assets")
--}
--Tables{
local effects = {}
--}
function effects:Skill()
print("aaaa")
return
end
function effects:Splash(cfr, yPos)
local splashInfo = TweenInfo.new(1.95, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out)
local shockInfo = TweenInfo.new(.75, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local shockProperty = {Transparency = 1, Size = Vector3.new(20, 1.75, 20)}
local splashProperty = {Transparency = 1, Size = Vector3.new(15, 20, 15)}
local splash = assets:WaitForChild("Splashwave")
local shock = assets:WaitForChild("ShockwaveA")
local newShock = shock:Clone()
newShock.BrickColor = BrickColor.new("Electric blue")
newShock.CFrame = cfr
newShock.Position = Vector3.new(cfr.X, yPos, cfr.Z)
local newSplash = splash:Clone()
newSplash.BrickColor = BrickColor.new("Electric blue")
newSplash.CFrame = newShock.CFrame * CFrame.new(0, -0.25, 0)
newSplash.Transparency = 0
splashProperty.CFrame = newSplash.CFrame * CFrame.new(0, (splashProperty.Size.Y / 2), 0)
newShock.Parent = workspace
local tween = tweenService:Create(newShock, shockInfo, shockProperty)
tween:Play()
local splashTween = tweenService:Create(newSplash, splashInfo, splashProperty)
local foundSound = soundService:FindFirstChild("Splash")
runService.RenderStepped:Wait()
newSplash.Parent = workspace
splashTween:Play()
debris:AddItem(newShock, shockInfo.Time)
debris:AddItem(newSplash, splashInfo.Time)
local soundEffect = foundSound:Clone()
soundEffect.Parent = newSplash
soundEffect:Play()
return
end
return effects
Any errors, screenshots, or videos included could help. Can’t do much without knowing what the problem is. If there is no errors, you may need to elaborate on what’s breaking exactly.
Sorry if I explained it bad. It works perfectly if it uses meshes in the asset folder. But whenever I switch the meshes to models with the same name it fails to work. This is a module script script and here’s its’ parent script incase that helps. It’s parent script is a local script in ReplicatedFirst. The asset folder is in ReplicatedStorage:
--Services{
local replicatedStorage = game:GetService("ReplicatedStorage")
local playerService = game:GetService("Players")
--}
--Variables{
local bindables = replicatedStorage:WaitForChild("Bindables")
local remotes = replicatedStorage:WaitForChild("Remotes")
local effectModule = script:WaitForChild("EffectModule")
local player = playerService.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
player.CharacterAdded:Connect(function(char)
character = char
end)
--}
--Remotes{
local clientEffect = remotes:WaitForChild("ClientEffect")
local playEffect = bindables:WaitForChild("PlayEffect")
--}
--Tables{
local effectLibrary = require(effectModule)
--}
local function startEffect(effectName, ...)
local setEffect = effectLibrary[effectName]
if setEffect ~= nil then
setEffect(effectName, ...)
end
end
clientEffect.OnClientEvent:Connect(startEffect)
playEffect.Event:Connect(startEffect)
local seaValue = script:WaitForChild("SeaValue")
local ocean = seaValue.Value:WaitForChild("Ocean")
ocean.Touched:Connect(function(otherPart)
if otherPart:IsDescendantOf(character) then return end
local model = otherPart.Parent
if otherPart.Name == "HumanoidRootPart" and playerService:GetPlayerFromCharacter(model) ~= nil then
local distanceCheck = (character:GetPivot().Position - model:GetPivot().Position).Magnitude
if distanceCheck <= 225 then
game.ReplicatedStorage.Bindables.PlayEffect:Fire("Splash", otherPart.CFrame)
end
end
end)
Well the difference between meshes and models is models have a seperate way of transforming. Usually by Model:SetPrimaryPartCFrame or Model:PivotTo. I’m not sure if you have that included, but you could try replacing what you have with one of these.
I’m a little confused by what you meant . I tried to add this to my script but it didn’t work. Do you know why?
This is the module script from the Original Post:
--Services{
local replicatedStorage = game:GetService("ReplicatedStorage")
local tweenService = game:GetService("TweenService")
local soundService = game:GetService("SoundService")
local runService = game:GetService("RunService")
local debris = game:GetService("Debris")
--}
--Vars{
local assets = replicatedStorage:WaitForChild("Assets")
--}
--Tables{
local effects = {}
--}
function effects:Skill()
print("aaaa")
return
end
function effects:Splash(cfr, yPos)
local splashInfo = TweenInfo.new(1.95, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out)
local shockInfo = TweenInfo.new(.75, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local shockProperty = {Transparency = 1, Size = Vector3.new(20, 1.75, 20)}
local splashProperty = {Transparency = 1, Size = Vector3.new(15, 20, 15)}
local splash = assets:WaitForChild("Splashwave")
local shock = assets:WaitForChild("ShockwaveA")
-- Clone models instead of meshes
local newShock = shock:Clone()
newShock.BrickColor = BrickColor.new("Electric blue")
-- Set PrimaryPart and position of the shock model
newShock.PrimaryPart = newShock:WaitForChild("PrimaryPart") -- Ensure the model has a PrimaryPart set
newShock:SetPrimaryPartCFrame(cfr)
newShock.PrimaryPart.Position = Vector3.new(cfr.X, yPos, cfr.Z) -- Ensure correct Y position
local newSplash = splash:Clone()
newSplash.BrickColor = BrickColor.new("Electric blue")
-- Set PrimaryPart and position of the splash model
newSplash.PrimaryPart = newSplash:WaitForChild("PrimaryPart") -- Ensure this model has a PrimaryPart
newSplash:SetPrimaryPartCFrame(newShock.PrimaryPart.CFrame * CFrame.new(0, -0.25, 0))
newSplash.Transparency = 0
-- Set splash property transformation
splashProperty.CFrame = newSplash.PrimaryPart.CFrame * CFrame.new(0, (splashProperty.Size.Y / 2), 0)
-- Set the parent of the models
newShock.Parent = workspace
local tween = tweenService:Create(newShock, shockInfo, shockProperty)
tween:Play()
local splashTween = tweenService:Create(newSplash, splashInfo, splashProperty)
local foundSound = soundService:FindFirstChild("Splash")
runService.RenderStepped:Wait()
newSplash.Parent = workspace
splashTween:Play()
debris:AddItem(newShock, shockInfo.Time)
debris:AddItem(newSplash, splashInfo.Time)
local soundEffect = foundSound:Clone()
soundEffect.Parent = newSplash
soundEffect:Play()
return
end
return effects
I managed to do it by lots of spaghetti code and using PivotTo so thanks for recommending this. I read the page about it and understood it better!
-- Services
local replicatedStorage = game:GetService("ReplicatedStorage")
local tweenService = game:GetService("TweenService")
local soundService = game:GetService("SoundService")
local runService = game:GetService("RunService")
local debris = game:GetService("Debris")
-- Vars
local assets = replicatedStorage:WaitForChild("Assets")
-- Tables
local effects = {}
function effects:Skill()
print("aaaa")
return
end
function effects:Splash(cfr, yPos)
-- Define the tween properties for the shockwave
local shockInfo = TweenInfo.new(0.75, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local shockProperty = {Transparency = 1, Size = Vector3.new(20, 1.75, 20)}
-- Get the ShockwaveA model
local shock = assets:WaitForChild("ShockwaveA")
-- Adjust Y position for the shockwave to make it higher
local adjustedYPos = yPos + 5 -- Adjusted Y position for shockwave
-- Clone the ShockwaveA model and adjust its position
local newShock = shock:Clone()
newShock:PivotTo(CFrame.new(cfr.X, adjustedYPos, cfr.Z)) -- Set the shockwave position
-- Parent the model to the workspace
newShock.Parent = workspace
-- Initialize the transparency to 0
local transparency = 0
for i = 0, 100 do -- Changes frames: 100 frames for 1 second duration
runService.RenderStepped:Wait()
transparency = transparency + 0.01
-- Update the transparency of each part
for _, part in ipairs(newShock:GetChildren()) do
if part:IsA("BasePart") then
part.Transparency = transparency
end
end
end
-- Find and play the sound effect
local foundSound = soundService:FindFirstChild("Splash")
runService.RenderStepped:Wait()
-- Clone and play the sound effect
local soundEffect = foundSound:Clone()
soundEffect.Parent = newShock
soundEffect:Play()
-- Clean up after the shockwave is finished
debris:AddItem(newShock, 1)
return
end
return effects