Script not working. Pleeeeease help

OKKKKKKKK
So now With help i’ve been able to fix everything except for the damage part of the flamethrower.

The server script trying to recieve it: (server)

local storage = game.ReplicatedStorage

local event = storage.Cooler



local function onActivation()

print('omg this is working')

	script.Parent.Touched:Connect(function(hit)
		local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
		if humanoid then
			humanoid:TakeDamage(3)
		end
	end)




end


event.OnServerEvent:Connect(onActivation)

First of all, you should never reference items inside server scripts and module scripts.
Second of all, is the server script inside the ServerScriptService?

  1. ok
  2. Though the script has to be the child of the hitbox in order to work.

though isnt those suggestions the same thing as how I wrote them?

Those things (ReplicatedStorage and Cooler) might not be loaded into the game by the time your script references them.

In which case it will throw an error

1 Like

So change everything to waitforchild?

1 Like

Only for the remote events that you defined first in your script

1 Like

So like this?


local storage = game:WaitForChild('ReplicatedStorage')

local event = storage:WaitForChild('Cooler')



local function onActivation()

print('omg this is working')

	script.Parent.Touched:Connect(function(hit)
		local humanoid = hit.Parent:WaitForChildWhichIsA("Humanoid")
		if humanoid then
			humanoid:TakeDamage(3)
		end
	end)




end


event.OnServerEvent:Connect(onActivation)

This is incorrect. Unless the object has to be created by another script during runtime, server scripts don’t need to use :WaitForChild(). Only LocalScripts would need to use them in this situation.

Not for replicatedstorage you should do

local storage = game:GetService("ReplicatedStorage")

Well ive done everythign you have said but it still doesnt work and there are no errors still…

When making a ColorSequence with more than two colors, you need to create a table of ColorSequenceKeypoints and create a ColorSequence with that table. See here

1 Like

Are you sure?

I just tool out the part that defined the particle’s rate and the particles show up, everything works except for the damage when i take away the rate definer

And the print statement doesnt work also so the remote events dont work

Edit: nvm ur right the colorsequence is only playing 2 colors

Sometimes the server tries to define variables that aren’t there, so wouldn’t the server need to use WaitForChild to make sure the script hasn’t loaded before the objects? I’ve second guessed myself now lol

Edit: it took me a second for my brain to click but yes i am wrong

Either way, your ColorSequence isn’t exactly how you want it to be. What your constructor actually makes is a ColorSequence with only two colors. The first and second in the arguments you passed.
image

ye your right my bad. Could you show me the table you wrote out again?

The table I wrote in my original reply wasn’t correct. What you need to do is turn your colors into ColorSequenceKeypoints. It should look like this:

1 Like

ok. Btw do you know why the rate definer is breaking the script?

(look at the edit I made in the post)

The rate definer breaks your script because you’re setting it to a NumberRange value when it’s supposed to be a number.

ok thanks. i wrote out a table for the color sequence and it isnt working do you know what I did wrong?

		ball.Color = ColorSequence.new{
			ColorSequenceKeypoint.new(Color3.new(1, 0, 0),Color3.new(1, 0, 0)),
			ColorSequenceKeypoint.new(Color3.new(1, 0.666667, 0),Color3.new(1, 0.666667, 0)),
			ColorSequenceKeypoint.new(Color3.new(1, 1, 0),Color3.new(1, 1, 0)),
			ColorSequenceKeypoint.new(Color3.new(1, 0.945098, 0.721569),Color3.new(1, 0.945098, 0.721569))
	
		}