Hello does anyone know how to fix the lavadamage script from the Jurassic World Volcano Challenge event ages ago curious as wanna re-open the game with new updates (just to be clear this script is from Jurassic World Volcano Challenge event ages ago)
Edit: it work in studios but not in game confused
forgot to say this script is in ( ServerScriptService )
-- Amount of damage players will take when standing in lava local LAVA_DPS = 300 -- Roblox Services local Players = game:GetService("Players") local RunService = game:GetService("RunService") -- Tables to keep track of which characters are on fire local charactersOnFire = {} local signalBindings = {} -- Create and configure the fire local function createFire() local fire = Instance.new("Fire") fire.Enabled = false fire.Size = 10 return fire end -- Called when a new character model is created local function onCharacterAdded(character) local humanoid = character:WaitForChild("Humanoid") local humanoidRootPart = character:WaitForChild("HumanoidRootPart") local floorChangedSignal = humanoid:GetPropertyChangedSignal("FloorMaterial") -- Create fire effect to show the player if they are taking damage local fire = createFire() fire.Parent = humanoidRootPart -- Connects function to when the floor under the character changes signalBindings[character] = floorChangedSignal:Connect(function() -- If the character is standing on lava, add them to the list of on fire -- characters and turn on the fire effect. Otherwise to the opposite if humanoid.FloorMaterial == Enum.Material.CrackedLava then charactersOnFire[character] = true fire.Enabled = true else charactersOnFire[character] = nil fire.Enabled = false end end) end -- Clean up the event connections when a character model is removed local function onCharacterRemoving(character) if signalBindings[character] then signalBindings[character]:Disconnect() end if charactersOnFire[character] then charactersOnFire[character] = nil end end -- Set up character event binding when player joins the game local function onPlayerAdded(player) player.CharacterAdded:Connect(onCharacterAdded) player.CharacterRemoving:Connect(onCharacterRemoving) end -- Game update loop local function onHeartbeat(delta) local damage = LAVA_DPS * delta -- Go through all of the characters on fire and make them take damage for character in pairs(charactersOnFire) do local humanoid = character:FindFirstChildOfClass("Humanoid") if humanoid then humanoid:TakeDamage(damage) end end end -- Connect functions to events Players.PlayerAdded:Connect(onPlayerAdded) RunService.Heartbeat:Connect(onHeartbeat)
Alright so two things. Ill give you solution and suggestions on how to rewrite your code to improve it. Alright so first, adding the characters to the table to be checked. The way you do it is more likely to cause errors. The thing is i dont exactly know what those logic errors are, but i wouldnt add characters to a table the way you are doing it, in the first place. And all my adding-character-to-table scripts work fine. SO here is my way and a better way to do it.
local charTable = {} table.insert(charTable, char) -- adds character table.remove(charTable , table.find(charTable , character)) -- removes character -- this is an example of how to go through each one in for loop for key, value in pairs(charactersOnFire) do -- character is the value instead of the key. This could be the only problem, but im just giving you a better way to rewrite everything. end
Instead of making character = true in the table (which is basically the same as the following but with extra steps), just add and remove the character completely from the table. This is the most simple way to do it and it is far less likely to cause errors. When coding, please try doing the most simple things so as to reduce the chance of logic errors and other errors.
Second, humanoid:GetPropertyChangedSignal"FloorMateral" for some reason only fires twice upon joining. And after that it does not work. But constantly printing the humanoid's floormaterial showed me it did still work and i could see when i was on cracked lava but it still didnt fire propertychanged signal thing. After a lot of research I have three solutions that are kind of hacky, but thats often the case with roblox since roblox is garbage.
1) Use a remotevent. Detect the floormaterial on the client side and then send it using remoteevent. And then take action on serverside. Dont worry about exploiters stopping the remote event from functioning, because if an exploiter can do that, they might as well use flying or any other technique to stop themselves from walking on lava so it doesnt matter anyway. I tried the proeprtychanged signal thing and it works CLIENT SIDE but not SEVER SIDE. It just doesnt seem to trigger propertychange signal server side even though the floor material does change server side. No clue why.
2) since you can read the humanoids floormaterial, you can constantly check it with while true do loop. Again, getpropetychanged signal just isnt being fired serverside.
3) Maybe you could try using another function?
Read this maybe it tells you WHY it doesnt trigger propertychangedsignal of humanoids floormaterial serve side : https://create.roblox.com/docs/reference/engine/classes/Humanoid#FloorMaterial
Im stumped so this is all imma do. Hope this helps. I was surprised it didnt work, getpropertychanged signal on humanoids floormaterial server side.
Edit: I checked the link that i said might explain why it doesnt fire and i think i know why now. It says FloorMaterial is NOT REPLICATED. Which i believe means it doesnt replicate it from client to server side. So I think FloorMaterial is only meant to be used on client side. So if you really want to check what material humanoid is standing on from SERVER SIDE, try using raycast or something.
Second edit: THE ANSWER IS RAYCAST. Floormaterial is apparently just a raycast downwards client side. So you can do the same on the server.